How can I destroy a custom typed object manually?
e.g, I declared a class named “A”, then I instantiated it by the keyword “new”:
var myObject : A = new A();
Now I wanna release the memory of myObject from the heap, how can I do it? I can’t find a keyword like “delete”.
Once nothing refers to the variable the memory will be freed automatically by the garbage collector. If you want to run the garbage collector manually you can call System.GC.Collect(), but most of the time it works better if you just leave it to do its job.
This page has some info on when it might be useful to do gc manually.