Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Memory Leak When Registering Implicit Reference Cast for Template


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Jason Goepel   Members   -  Reputation: 372

Like
0Likes
Like

Posted 26 February 2014 - 04:18 PM

I haven't had the time to generate a simplified example of this bug yet, but I figured I would report it while I work on one.

 

I found that under certain conditions a "asBEHAVE_IMPLICIT_REF_CAST" behavior will leak.  Here is what I know.

 

- There is no leak if I do not register any "asBEHAVE_IMPLICIT_REF_CAST" behavior.

- There is no leak if I do not register any template specializations.

- The leaked behavior is the one created during the registration of the template class, NOT the specialization.

 

It appears that registering the template specializations (or the asBEHAVE_IMPLICIT_REF_CAST behaviors in those specializations) is preventing the proper cleanup of the asBEHAVE_IMPLICIT_REF_CAST behaviors in the template class.

 

I will try to develop a simplified example, but there are a lot of elements involved.  Let me know if you are able to reproduce the leak so I don't have create the example.

 

If there is anything I can 

 

The leaked memory is allocated with the asNEW calls in asCScriptEngine::AddBehaviourFunction

int asCScriptEngine::AddBehaviourFunction(asCScriptFunction &func, asSSystemFunctionInterface &internal)
{
	asUINT n;

	int id = GetNextScriptFunctionId();

	asSSystemFunctionInterface *newInterface = asNEW(asSSystemFunctionInterface)(internal);
	if( newInterface == 0 )
		return asOUT_OF_MEMORY;

	asCScriptFunction *f = asNEW(asCScriptFunction)(this, 0, asFUNC_SYSTEM);
	if( f == 0 )
	{
		asDELETE(newInterface, asSSystemFunctionInterface);
		return asOUT_OF_MEMORY;
	}

	asASSERT(func.name != "" && func.name != "f");
	f->name           = func.name;
	f->sysFuncIntf    = newInterface;
	f->returnType     = func.returnType;
	f->objectType     = func.objectType;
	f->id             = id;
	f->isReadOnly     = func.isReadOnly;
	f->accessMask     = defaultAccessMask;
	f->parameterTypes = func.parameterTypes;
	f->inOutFlags     = func.inOutFlags;
	for( n = 0; n < func.defaultArgs.GetLength(); n++ )
		if( func.defaultArgs[n] )
			f->defaultArgs.PushLast(asNEW(asCString)(*func.defaultArgs[n]));
		else
			f->defaultArgs.PushLast(0);

	SetScriptFunction(f);

	// If parameter type from other groups are used, add references
	if( f->returnType.GetObjectType() )
	{
		asCConfigGroup *group = FindConfigGroupForObjectType(f->returnType.GetObjectType());
		currentGroup->RefConfigGroup(group);
	}
	for( n = 0; n < f->parameterTypes.GetLength(); n++ )
	{
		if( f->parameterTypes[n].GetObjectType() )
		{
			asCConfigGroup *group = FindConfigGroupForObjectType(f->parameterTypes[n].GetObjectType());
			currentGroup->RefConfigGroup(group);
		}
	}

	return id;
}

I have attached my engine configuration.  I have reduced it quite a bit, but it still shows the leak.  I am noticing that even though I registered a template specilization Array<int8> it doesn't show in the configuration file.  I hope this helps.

Attached Files



Sponsor:

#2 Jason Goepel   Members   -  Reputation: 372

Like
0Likes
Like

Posted 26 February 2014 - 04:55 PM

Upon further investigation, the leak is not the worst of my problems.  The implicit reference cast isn't called when it should, even though it was registered.  Perhaps it got replaced somewhere in the registration process.



#3 Andreas Jonsson   Moderators   -  Reputation: 3240

Like
0Likes
Like

Posted 26 February 2014 - 05:15 PM

I'll investigate this. Thanks.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#4 Andreas Jonsson   Moderators   -  Reputation: 3240

Like
0Likes
Like

Posted 01 March 2014 - 11:36 AM

I've fixed the memory leak in revision 1860.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS