Hi
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