Automatic garbage collection?

BlitzMax Forums/BlitzMax Programming/Automatic garbage collection?

sswift(Posted 2006) [#1]
There was something in the help file about garbage collection defaulting to automatic... And I remember Mark saying something about him being crazy for setting it up the way he did.

So do you have to worry about garbage collection anymore if it is left on automatic, or what?

Also, does delete exist, or not? The help file says no, but someone in another thread told me that I create and delete types with new and delete, which seems to indicate it exists.


N(Posted 2006) [#2]
Given proper design you shouldn't have to worry. Still, throwing a GCCollect() into pretty memory intensive areas would probably help.

Delete does not exist. You can override the Delete method of a type so you can do specific stuff when the object is collected by the GC, but that's all.

I wrote a function that would 'forcefully' reduce the reference count of an object to zero (e.g., even if there were still references, the object was dead weight as far as the GC was concerned) at one time -- trust me, it doesn't work.


sswift(Posted 2006) [#3]
"I wrote a function that would 'forcefully' reduce the reference count of an object to zero (e.g., even if there were still references, the object was dead weight as far as the GC was concerned) at one time -- trust me, it doesn't work."


Are you saying you were trying to find a bug with it?

If so, here's an idea. Save the pointer to a file. Then set the pointer in the program to null. You still know where it is, but I bet the GC doesn't know you know where it is. :-)
Obviously not something one is likely to do in the real world though.


N(Posted 2006) [#4]
Are you saying you were trying to find a bug with it?


No, I was trying to find a way to force the collection of memory.


sswift(Posted 2006) [#5]
I see. But I don't see why you would want to do that.


N(Posted 2006) [#6]
For the hell of it.