Question about Destructor()
BlitzMax Forums/BlitzMax Programming/Question about Destructor()
| ||
Hi guys, Delete method is never called when I destroy Type Test. What is wrong here :) SuperStrict Type Test Field a:Int Field list:TList=New TList Method New() Print "Object Created" For Local i:Int=0 To 100 list.AddLast("item_"+i) Next End Method Method Delete() Print "Object Deleted" End Method EndType Local t:Test = New Test t = Null GCCollect Thanks |
| ||
The GC will not collect until there is enough stuff to do so. Create some thousand of your objects and it will start working. Last edited 2012 |
| ||
Thanks I thought that GCCollect works instantly . :) |
| ||
More or less yes, but if this is your entire program then it ends after the G CCollect and it could be well possible that it ends execution before it gets to GCCollect can finish. |
| ||
Deleting objects waist CPU time, so it is only done when it is required. Sometimes it does not get called at all, if the amount of mem to free is not significative (it'll be freed when/if there are enought objects to free that it's worth it). |
| ||
Thanks guys for your help |