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

[REBOL] Re: Memory issues

From: rebol:techscribe at: 26-Jan-2001 12:04

Hi Paul, Paul Tretter wrote:
> recycle
REBOL has automatic garbage collection and will free previously allocated memory that is no longer needed by itself. You can optionally instruct REBOL to free up memory by using recycle. I would use recycle in two (three) situations, namely when I want to better control at which point in time REBOL spends machine cycles on freeing previously allocated memory a) When I know that I am about to do something that is very memory intensive, and I want to avoid having REBOL free up memory repeatedly while it is evaluating my memory intensive functions; So I force REBOL to reclaim unused memory hoping that this will provide for a large enough available memory pool and REBOL will not have to interrupt the evalution of the following instructions in order to free up memory; b) When I know that I have just used up a huge amount of memory, and I want to avoid having REBOL repeatedly reclaim unused memory as needed during the evaluation of the following code; c) This is a combination of a and b: During the repreated evaluation of memory intensive functions I want to better control at which point memory that is no longer needed should be freed.
> clear
The clear function empties a series value, such as a block or a string. Elements whose reference count has fallen to zero will be automatically garbage collected (or garbage collection can be forced with recycel).
> free
When you load a shared library (or dll) under /Command then the resources associated with that library must be explicitly freed using free. These resources are not included in the garbage collection, since REBOL has no way of knowing if the DLL or shared library is still using that resource internally.
> unset
Unset dis-asscoiates a word from its value. Unset reduces the reference count of a value, and if the reference count has dropped to 0 the value will be garbage collected, and the memory it occupies will be freed. Comparing clear to unset: If I use clear I reclaim the memory used by the elemnts of a series value, but the series value itself, and the word associated with it, continue to exist and occupy memory. If I use unset instead of clear, then not only will the element be garbage collected, but in addition, the series value itself is disposed of, and the word is no longer associated with a value. Hope this helps, Elan