[unset] Memory optimization idea
[1/2] from: atruter:labyrinth:au at: 21-Jan-2004 14:13
It occurred to me that there are a lot of functions (both native! and
mezzanine), even with REBOL/Base, that are never used in my scripts. I
sometimes 'unset the larger of these to minimize REBOL's memory footprint,
which got me to thinking that it might be possible to create a 'func to do
this for me. The logic would go something like this:
pre-unset
funcs: obtain a list of all globally defined functions (use 'what as a
template)
script
post-unset
remove-each from funcs where func appears in script
remove-each from funcs where func appears in funcs/mezz
foreach func funcs [unset 'func]
unset 'pre-unset
unset 'self
recycle
Which should work so long as native! func's don't depend on other func's
(native! or not). If this concept works, it could then be extended to
other (eg. VID) words so long as the script does not create dynamic
references (which is rare for non-user defined words in my scripts at
least).
What I was hoping is that there might be an easy way to answer the
question, "Which words in the global context are not being used, and can
they be unset safely?".
Comments?
Regards,
Ashley<
[2/2] from: greggirwin::mindspring::com at: 20-Jan-2004 22:40
Hi Ashley,
AT> What I was hoping is that there might be an easy way to answer the
AT> question, "Which words in the global context are not being used, and can
AT> they be unset safely?".
The best way is to get the SDK and only include the parts you need
with the kernel of your choice. Barring that, I think the savings
(aside from VID stuff--use Core or Base if you don't need it) is not
worth the effort. "not being used" and "not being used _yet_" are very
close but quite different. :)
Please let us know if you've done any measurements to see how much
memory you save with your efforts!
-- Gregg