Jump to content
  • Advertisement
Sign in to follow this  
FDsagizi

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

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

Edited by FDsagizi

Share this post


Link to post
Share on other sites
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

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!