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

[REBOL] make list 0 versus make list [] Re:

From: galtbarber:mailandnews at: 28-Aug-2000 14:36

> In both cases, Rebol will expand or contract the list as required to hold > the data in the list.
It is true that Rebol will expand memory for a block or list automatically, although you can help speed it up by pre-initializing to a large number of elements if you know they will be needed. In the case of a block, however, I think it does not release memory automatically. I think it holds onto the largest memory that instance of the block has used in case you need that space again. So, it is quite possible that the same thing applies to lists, as far as system storage usage goes. Obviously, if you really knew that you had used tons of memory and that you wouldn't need that again, you could create a copy of the original that would be no larger than needed. b: make block! 10000000 [... do some stuff, now it is just small, but non-empty...] b: make block! b now b will point to a new smaller block, I hope, and the big original should be garbage recycled. of course if that didn't work, this should work: b: copy b Anyway, I am not sure how to check the exact amount of ram used accurately. Recycle seems to help sometimes, but I can't always get the memory reported by taskmgr to show it's minimum value, so Rebol must be hanging onto some ram in case the user asks for more later. Can someone out there enlighten us? Thanks, -Galt p.s. for most of my programs, I don't bother to pre-initialize the size. I think that's not necessary unless you have a specific small bit of code that must be highly optimized for speed, which is usually not the case for my own programs.