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

Memory issues

 [1/3] from: ptretter::norcom2000::com at: 26-Jan-2001 14:44


Thanks for the quick and details response ELAN. I am quickly putting your comments into practice in my script. Thanks Again. Paul Tretter ----- Original Message ----- From: "Elan" <[rebol--techscribe--com]> To: <[rebol-list--rebol--com]> Sent: Friday, January 26, 2001 2:04 PM Subject: [REBOL] Re: Memory issues
> Hi Paul, > Paul Tretter wrote:
<<quoted lines omitted: 43>>
> > > > What are the advantages or disadvantages of each. 'Free apears to be
only available in /Command version. I am very interested in this with a script that I am working on that is getting a bit memory intensive.

 [2/3] from: ptretter:norcom2000 at: 26-Jan-2001 13:05


Can anyone provide more information regarding 'recycle and when to use it - help provides very little information. Also, when should variable or words be unset or cleared. Its hard to identify exactly when to use: recycle clear free unset Did I miss any? What are the advantages or disadvantages of each. 'Free apears to be only available in /Command version. I am very interested in this with a script that I am working on that is getting a bit memory intensive. Paul Tretter

 [3/3] 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

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted