Advertisement

Memory leak in virtual properties

Started by June 30, 2013 11:24 AM
3 comments, last by WitchLord 11 years, 4 months ago

First of all, thanks for creating such wonderfull library. When adding a virtual property in a class IE:


    int mInt
    {
        get
        {
            return 0;
        }
    }

visual studio 2012 detects a memory leak on the following new statement:

asCParser::ParseVirtualPropertyDecl() => asCParser::SuperficiallyParseStatementBlock() => asCParser::CreateNode(eScriptNode type)

I am using the latest version (angelscript 2.26.3)
.

Thanks

Thanks. I'll look into it.

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

Advertisement

I can't reproduce the memory leak with just the following:


{
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
 
asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
mod->AddScriptSection("test", 
"class Test { \n"
" int mProp { \n"
"   get { \n"
"     return 0; \n"
"   } \n"
" } \n"
"} \n");
r = mod->Build();
if( r < 0 )
TEST_FAILED;
 
engine->Release();
}

The leak likely occur in combination with something else. Can you provide more information about the scenario in which you caught the memory leak?

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

I was able to sandbox the leak with the following:

Create a file 'test1.as'


shared class TestClass {
    int mProp {
        get {
            return 0;
        }
    }
}

Create a file 'test2.as'


#include "test1.as"
class TestClass2
	: TestClass
{
}

Now execute this code:


{
    asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
    CScriptBuilder builder, builder2;
    asIScriptModule *mod;
    builder.StartNewModule( engine, "test1" );
    builder.AddSectionFromFile("test1.as");
    builder.BuildModule();
    mod = builder.GetModule();
    builder2.StartNewModule( engine, "test2" );
    builder2.AddSectionFromFile("test2.as");
    builder2.BuildModule();
    mod = builder2.GetModule();
    engine->Release();
}

The 'shared' on the class TestClass is necessary to reproduce this.

Thanks a lot. I should have suspected it was in combination with shared classes.

I've fixed this memory leak in revision 1659.

Regards,

Andreas

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

This topic is closed to new replies.

Advertisement