Is there a reason why the Delete() method never...

BlitzMax Forums/BlitzMax Programming/Is there a reason why the Delete() method never...

Gabriel(Posted 2006) [#1]
never gets called?

Just wondered. For some reason, it's never been called for me. Just something simple like an object which never gets passed around anywhere. I put it into a TList when it's created and then only address it by cycling through all entries on the list. When I'm done with it, I remove it from the list and if the list is empty, I nullify the list too.

The list gets nullified so the list is certainly empty. But the delete method is never called. It never has been in any code I've ever written. Just wondered if it's a bug or if it's only supposed to be called under certain circumstances.


N(Posted 2006) [#2]
Seems to work fine here:

Type Blah
    Method Delete( )
        Print "Deleted"
    End MEthod
End Type

New Blah
GCCollect( )
GCCollect( ) ' Not quite sure why I have to call it twice.
Input( )



FlameDuck(Posted 2006) [#3]
GCCollect( ) ' Not quite sure why I have to call it twice.
I don't have to.


Azathoth(Posted 2006) [#4]
I made a post about this awhile ago. Turns out delete only gets called by the gc, if the gc doesn't collect the object by the end of the program delete doesn't get called at all, Blitzmax leaves it up to the OS.


Dreamora(Posted 2006) [#5]
Not that sure on that as Win98 / ME would never release any memory then ;-)

BM will fully clear it but if it happens on End, then it does not use delete anymore but fully cleans its whole allocated memory without "OO overhead".


Gabriel(Posted 2006) [#6]
Hmm yes, on further investigation, it seems that GCCollect does nothing for me, and that the garbage collector clears things up whenever it feels like regardless of whether or not I use GCCollect. It's pretty random. In Noel's example, one GCCollect call is fine, and yet in other code, it ignores all calls to GCCollect. Maybe things are improved in 1.16 ( still on 1.14 )