Sign in to follow this  
Myran

Reference type memory leak?

Recommended Posts

Myran    147

So I have a reference type where i register the asBEHAVE_ADDREF and asBEHAVE_RELEASE behaviours, and I construct this reference type in C++. So in AngelScript I have a C++ method that returns this reference type, but if I never assign the returned value to anything the reference behaviours are never called so the object never gets deleted. Is there something I can do to detect this or have I done something wrong?

 

 

So basically this leaks memory:

sound.Play2D();

 

and this does not:

SoundInstance@ si = sound.Play2D();

Share this post


Link to post
Share on other sites
WitchLord    4678

There should not be any memory leak in either case.

 

 

How have you registered Play2D()? And how is it implemented?

 

 

If you have registered it to return a handle, i.e. "SoundInstance @Play2D()" then the implementation should increment the ref count for the returned handle. AngelScript will then call Release() on it when it is no longer used (even if you don't explicitly assign it to any variable).

 

If you have registered it to return a reference, i.e. "SoundInstance &Play2D()" then the implementation must not increment the ref count for the returned reference, as AngelScript will not call Release() on it.

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