PDA

View Full Version : Deallocating Variables


Wahooney
11-14-2006, 10:38 AM
Is there a way to deallocate an array (or any other variable) in maxscript?

Something like: delete []array; in C++

gc() seems to slow the script I'm working on quite a bita when all I need is to deallocate the same array a through a few loops.

rdg
11-14-2006, 10:46 AM
just an idea:

theArray = #()

only guessing ...

Georg

Wahooney
11-14-2006, 10:48 AM
No, I think that just creates a new array, the old array will still be in memory waiting for garbage collection.

erilaz
11-14-2006, 02:39 PM
I've used this in the past:

theArray.count = 0

It clears the array... not sure about the memory though.

Bobo
11-14-2006, 05:20 PM
I've used this in the past:

theArray.count = 0

It clears the array... not sure about the memory though.

Generally, the memory will be released at the next manual or automatic garbage collection, both light and full.

If you want to clean up manually, call

gc light:true

This will clean up memory that is NOT related to the scene objects, will preserve the undo stack and will be much faster than full gc().
Max 8 and 9 have much better automatic garbage collection which calls gc light:true internally whenever memory is needed and would release whatever is left of the old arrays, variable values etc. too.

Wahooney
11-14-2006, 06:13 PM
Thanks Bobo, I was kinda afraid of that, even calling gc lite:true seems to slow my script down.

It's not a huge script so maybe it would be best if I just rewrote it, I might be able to speed things up a bit that way.

Thanks for all the help guys :thumbsup:

CGTalk Moderation
11-14-2006, 06:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.