asOBJ_VALUE | asOBJ_APP_CLASS_CD do not call Destructor on ARMv7

Started by
2 comments, last by WitchLord 10 years, 2 months ago

Hi smile.png

On Win32, Linux, MaxOs work fine, bug on - ARM( iPad )

after call C++ function, and pass in here asOBJ_VALUE type( my string's ), he create a copy, but not call destructor

simple code


void startGame(){
   MyStr m1;
   TestMyStrLeak( m1 );
}

C++


int con_count = 0;
int des_count = 0;

class MyStr{
public:
    MyStr(){
        std::cout << "CONSTR: " << ++con_count << "\n";
    }
    MyStr( const MyStr &other ){
        std::cout << "CONSTR Ohter: " << ++con_count << "\n";
    }
    ~MyStr(){
        std::cout << "DESTR: " << ++des_count << "\n";
    }
    static void Construct(MyStr *thisPointer){
        new(thisPointer) MyStr();
    }
    static void CopyConstruct(const MyStr &other, MyStr *thisPointer){
        new(thisPointer) MyStr(other);
    }
    static void Destruct(MyStr *thisPointer){
        thisPointer->~MyStr();
    }
};

void MemLeakMyStr( MyStr my_str ){
    std::cout << "L\n";
}

void RegMyStr( asIScriptEngine *en ){
    int r;
    r=en->RegisterObjectType("MyStr", sizeof(MyStr), asOBJ_VALUE | asOBJ_APP_CLASS_CD ); nu_assert( r >= 0 );
    r=en->RegisterObjectBehaviour("MyStr", asBEHAVE_CONSTRUCT,  "void f()",             asFUNCTION(MyStr::Construct), asCALL_CDECL_OBJLAST); nu_assert( r >= 0 );
    r=en->RegisterObjectBehaviour("MyStr", asBEHAVE_CONSTRUCT,  "void f(const MyStr &)",asFUNCTION(MyStr::CopyConstruct), asCALL_CDECL_OBJLAST); nu_assert( r >= 0 );
    r=en->RegisterObjectBehaviour("MyStr", asBEHAVE_DESTRUCT,   "void f()",              asFUNCTION(MyStr::Destruct),  asCALL_CDECL_OBJLAST); nu_assert( r >= 0 );
    r=en->RegisterGlobalFunction( "void TestMyStrLeak(MyStr name )",asFUNCTION(MemLeakMyStr),asCALL_CDECL);nu_assert(r>=0);
}

output:

CONSTR: 1

CONSTR Ohter: 2

L

DESTR: 1

Engine flags:

engine->SetEngineProperty(asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT, false);

engine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES, true);

engine->SetEngineProperty( asEP_ALLOW_IMPLICIT_HANDLE_TYPES, true );

engine->SetEngineProperty(asEP_AUTO_GARBAGE_COLLECT, true);

engine->SetEngineProperty( asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE, true );

engine->SetEngineProperty(asEP_COPY_SCRIPT_SECTIONS, true);

With ref type ( MyStr & name ) or generic type, work fine

Use last svn version

Advertisement

Can you try removing the following define from the as_config.h file?

#define AS_CALLEE_DESTROY_OBJ_BY_VAL

You'll find it in the area with the configuration for GNUC, APPLE, ARM (halfway into the file).

Let me know if that fixes the memory leak.

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

yes, its resolve problem

Thanks for confirming it. I've checked in the fix in revision 1818.

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