Quote:
Originally Posted by Earendil
All those things you are mentioning are Objects, once initialized with "new" a memory space is asigned to the object, using clear() will not free that memory space since objects still exist even if its content is removed.
Using delete causes to remove the assigned memory space, freeing it, but at a cost that you are required to initialize them again.
If you need to empty/fill an ArrayList multiple times, is better to use clear because is faster to skip the memory assignment. In the other hand is better to destroy objects and then initialize them if the data they are storing is big enough and is not required again.
Since SP has no garbage collector, allways delete handles once you don't need to use them anymore and always delete handles once you ended them in a code block. If not you will have memory leaks that will only be cleared after plugin unload.
And yeah, SourcePawn is not Object Oriented, but I imagine the lower layers of SM will work with objects, and ArrayLists and the other things are basically SM objects that we access via Handles.
|
Thank you, good to know, I will be more careful in the future.
__________________