Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

asOBJ_VALUE | asOBJ_APP_CLASS_CD do not call Destructor on ARMv7


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 24 January 2014 - 10:47 AM

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, 24 January 2014 - 10:50 AM.


Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3240

Like
0Likes
Like

Posted 24 January 2014 - 03:09 PM

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

#3 FDsagizi   Members   -  Reputation: 514

Like
0Likes
Like

Posted 25 January 2014 - 03:43 AM

yes, its resolve problem



#4 Andreas Jonsson   Moderators   -  Reputation: 3240

Like
0Likes
Like

Posted 25 January 2014 - 09:53 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS