HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

memory questions

09-11-2004, 01:47 AM#1
curi
do string vars need to be set to null to avoid leaks? is there a string destructor? i couldn't find one; does that mean all string usage leaks some? enough to matter?

is there a way to destroy arrays? if no does that mean they should be avoided locally? or if you clear everything out of them are they too small to matter?

are primitives automatically cleaned up, or how does that work? does setting integer vars to null do anything?

thanks in advance
09-11-2004, 01:59 AM#2
AIAndy
According to some tests strings actually leak, but it seems that only using different string literals leak. So having loads of strings with the content "aaa" will not leak. The leak is also not that big so unless you intend to use loads of different string literals it does not matter.
As long as you properly clear the content of the arrays they do not leak and are automatically destroyed.
Primitives are automatically cleaned up at the end of scope. No need to set to null (which btw is only necessary because of a bug).
09-15-2004, 04:19 PM#3
Cacodemon
You can read my post about strings (it was posted about 4-5 mounths ago) - they SURELY leak cause chunks allocated are not cleaned.

Every time you allocate new (combination of characters never allocated before) string, it causes memory leak:

Code:
set Str = "Hello" + ", World"

Will allocate 3 memory chunks: "Hello", ", World" and "Hello, World".

Code:
set StrA = "Hello" + ", World"
set StrB = "Hello" + ", My friend"

Will allocate 5 memory chinks: "Hello", ", World", "Hello, World", ", My friend" and "Hello, my friend".

This chunks may NOT be cleaned.