Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Some other questions

From: joel:neely:fedex at: 23-Nov-2003 0:01

Hi, Mike, Mike Loolard wrote:
> 4) In the same context: > how do I actually 'free' memory/variables ? >
You don't need to do so, as memory management in REBOL is automatic (including collection of circular garbage). However, if you are doing some processing of large structures, you can limit the need for REBOL to go back to the O/S and ask for more memory by clearing out stuff you no longer need. If you only have one word that refers e.g. to a large block, you can simply set that word to a trivial value, such as NONE, to make the previous contents available for garbage collection. blort: make block! 100000 repeat i 100000 [append blort sine i] ; whatever ; then, after that block is no longer needed... blort: none You can also use CLEAR to remove all values from a series (from the current position). This can be handy if you want to reuse the space after the initial contents are no longer needed. blort: make block! 100000 repeat i 100000 [append blort sine i] ; do something with sines clear blort repeat i 100000 [append blort cosine i] ; do something with cosines clear blort repeat i 100000 [append blort tangent i] ; do something with tangents ;... etc. But, again, unless you're working on huge structures, have a long- lived process, and are running on a small-memory or slow box, there's seldom any reason to worry about such things. -jn-