Noob Object Help Please

BlitzMax Forums/BlitzMax Beginners Area/Noob Object Help Please

@TonyG - Your example doesn't nullify test2, that's the point of interest. Having test1 recognize test2 is null. ;)

@Luni - Thanks for the explanation. I think I've got a solution. ;)

@ Brucey - Agreed. It's my implementation that is at fault.

Since I now fully understand that objects removed from a list are still alive until no references are made to them, I simply added another field to my objects that tells me if they are removed from the list.

The problem surfaced when I was adding code for homing missiles. If the baddie the missile was homing in on, was removed, I didn't know how to recognize this in code, because I had assumed the baddie was gone, but since there is a reference to the baddie via the missile, the baddie was still there just not in the update or render loops because it was removed from the list.

The solution was to simply add a field to the objects which tells me if they're removed from the list. So when a missile is homing in on a baddie that is removed, I can recognize this (and act on it) and also set the reference to null, which in turn will allow the garbage collection object to eventually remove the object. So I'm sure what was happening was, even though they were removed from the list and not being updated or rendered, they were still in memory taking up resources, etc. So now by setting the reference to null, it should allow everything to clean up correctly. ;)

Thanks for all the help!