Advertisement

memory leak bug

Started by March 26, 2010 09:30 AM
0 comments, last by WitchLord 14 years, 8 months ago
I found memory leak bug. Library Version: r575 Compiler: MSVC8

//-----------------------------------------------------------
// C++ source code
namespace
{
    // alloc counter
    int t_allocCount = 0;
    // alloc function
    void* t_alloc( const size_t aSize )
    {
        ++t_allocCount;
        return std::malloc( aSize );
    }
    // free cuntion
    void t_free( void* aPtr )
    {
        std::free( aPtr );
        --t_allocCount;
    }
}

int main(int argc, char **argv)
{
    // set allocator
    asSetGlobalMemoryFunctions( t_alloc , t_free );

    // Create the script engine
    asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);

    // Compile
    asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
    mod->AddScriptSection("script", 
        "class Hoge"
        "{"
        "    Hoge(){}"
        "    Hoge(HogeManager&){}"
        "};"
        "class HogeManager"
        "{"
        "    Hoge[] hoges;"
        "};"
        , 0);
    mod->Build();

    // Release engine
    engine->Release();

    // check
    assert( t_allocCount == 0 ); // assertion failed
}

Thanks for the report. I'll look into this.

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