Archive

Archive for March, 2010

Object/Dictionary Reference counting and Memory Management

March 7, 2010 Leave a comment

Since it is such an important topic and such a problem for the community, I thought I would make another post pertaining to optimizing for the garbage collector.

I was looking for information in the object/dictionary docs completely unrelated to memory management, but ran across this statement:

As long as any reference to the object exists, the garbage collection system will not recover the memory that the object occupies. If the value of myObject is changed such that it points to a different object or is set to the value null, the memory occupied by the original object becomes eligible for garbage collection, but only if there are no other references to the original object.

Wow.

Yes, you do need to explicitly set all non-simple types to null and splice/delete array indices and hash key entries.

Read more…