Sign in to follow this  
huangyous

can't release object with obj handle member

Recommended Posts

class C { C() {print("C()!!!"); } ~C() { print("~C..."); } C2@ c2; } class C2 {}; then in main(): C c(); it prints: C()!!! the deconstruction is never called! but when I define "c2" as "C2 c2" then it prints:C()!!! ~C... So what should I do to release object with handle member?

Share this post


Link to post
Share on other sites
As objects with members as handles can potentially form circular references the garbage collector keeps track of these instances.

So, you'll need to call engine->GarbageCollect() at an appropriate time to free this instance. The GC in AngelScript is not invoked automatically, as the game developer will in general want complete control over when it is supposed to run.

Regards,
Andreas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this