Object not being deleted - Why?

BlitzMax Forums/BlitzMax Programming/Object not being deleted - Why?

Hi,

The GC mechanism is tricky, and the ref counts wont always give a clear indication of what's going on.

The way the GC works, Max can optimize away pretty much all 'local' refs to objects, so a '1' ref count actually/usually implies there is a global (or field, or array element - ie: a memory ref) ref left.

There are other states a ref count can be in too - if the high bit is set, then it's a 'floating' ref - there are no global refs left and it's on an internal stack for (possible) later collection.

And this is all of course subject to change - if I get round to restoring the ability to debug while executing Delete() methods, this will probably require yet another internal stack somewhere. Play around with ref counts at your own peril!

As always, the acid test is: does your program leak memory over time?