This system is working fine, but I am getting memory leaks with instances. Right now I am trying this on "array" class (that comes along with angelscript).
Here is a very simple test I did (it does not do any loading, etc, I just wanted to explain why I am doing this at all),
First of all:
apDestData = mpScriptEngine->CreateScriptObjectCopy(apSrcAddr, alScriptId);
which I assume creates a copy of the script object in a pointer called apDestData.
I do nothing else with this pointer other than deleting a bit little later by doing:
pScriptEngine->ReleaseScriptObject(pData, typeId);
which does not seem to release the data of the new script object. (I checked and it did not call Release() in CScriptArray).
Also when finally running the script, it seems like the newly created object is still around, and its AddRef and Release is called every time the same function is called for the orginal object. My log output:
03CC6590 calling ref 3!
0B629DD8 calling ref 3!
03CC6590 calling release 3!
0B629DD8 calling release 3![/quote]
(the number is the refcount before dec or after add. 0B629DD8 is the data I created with CreateScriptObjectCopy)
Also when calling Script engine release I get very strange output:
3CC6590 calling ref 3!
0B629DD8 calling ref 3!
0B629DD8 calling release 3!
03CC6590 calling release 3!
03CC6590 calling release 2!
03CC6590 calling release 1!
0B629DD8 calling ref 3!
0B629DD8 calling release 3!
0B629DD8 calling ref 3!
0B629DD8 calling release 3!
0B629DD8 calling ref 3!
0B629DD8 calling release 3!
0B629DD8 calling ref 3!
0B629DD8 calling release 3!
0B629DD8 calling ref 3!
0B629DD8 calling release 3!
0B629DD8 calling ref 3!
0B629DD8 calling release 3!
0B629DD8 calling ref 3!
0B629DD8 calling release 3![/quote]
I cannot understand why all this happens.
So what am I doing wrong? Or is this perhaps some kind of bug?
EDIT:
Here is the script file (or rather the important bits from it):
class cTest {
OnStart() {
mvTest.insertLast(2);
mvTest.insertLast(3);
mvTest.insertLast(5);
mvTest.insertLast(7);
}
array<int> mvTest;
OnStart() is called once only.