• Hello everyone,

    We're happy to announce that our forum is back online! We needed to take some time off to discuss and decide on how to handle sensitive topics in our community.

    The team has posted an in-depth comment regarding a recent incident and our stance on politics and sexuality in our forum. We also added a dedicated paragraph about this in the forum guidelines. This is part of our commitment to maintain a welcoming and inclusive environment for all our users. Your understanding and continued support in building a creative and respectful community are highly appreciated.

    Thank you, the CX Dev-Team

Delete a instance [solved]

Jan_

New member
Joined
Oct 27, 2023
Messages
8
Good Evening,

how can i delete my class?

.delete
.free
=nil

Example:
Method update:Void(time:Int)
lifetime = lifetime + time
If ttl < lifetime Then
mylist.Remove(Self)
Self.???
EndIf
End
 
Last edited:
You cannot directly delete an object in memory. The simplest way is to make sure that the class object is not being referenced by any other variable. You do this by setting the variable to Null. When the garbage collector does it's next sweep. It will free the memory that was allocated.
 
Last edited:
The Image class has also a Discard method that you should use when an image is not referenced anymore.
 
The main point of garbage collection is that you don't have to - they will be auto-deleted when everything else has forgotten about them. But if you want to control things more, make an object pool for the things you want to control.
 
Back
Top Bottom