Jump to content
  • Advertisement
Sign in to follow this  

asOBJ_VALUE | asOBJ_APP_CLASS_CD do not call Destructor on ARMv7

This topic is 2097 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 );


int con_count = 0;
int des_count = 0;

class MyStr{
        std::cout << "CONSTR: " << ++con_count << "\n";
    MyStr( const MyStr &other ){
        std::cout << "CONSTR Ohter: " << ++con_count << "\n";
        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){

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);




CONSTR Ohter: 2




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

Edited by FDsagizi

Share this post

Link to post
Share on other sites

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




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.




Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!