• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualAndreas Jonsson

Posted 10 February 2012 - 08:26 PM

Quickly summarized, the problem is that when I assign a value from a c++ created object (handle) to a script created one, memory is not freed properly.

The code looks like this:
cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy = pCharBV;

This does not release the memory of cBoundingVolume (I am not sure of the exact script place the memory allocation takes place but can try and find out if needed) and I get a memory leak.

However,this code works just fine:

cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy;

GetBoundingVolume is a c++ function and has this declartion:
cBoundingVolume@+ GetBoundingVolume()

I am guessing that the problem might be that I am not declaring the copy operator correctly?
Currently it looks like this:
RegisterOperator("cBoundingVolume &opAssign(const cBoundingVolume &in)", asMETHODPR(cBoundingVolume, operator =, (const cBoundingVolume &), cBoundingVolume &)  );
Do I need to do something different for it to work? (as in increasing a user count in cBoundingVolume?)

I was not sure exactly what code is needed, so just say if you need to see more in order to locate the problem!

### #4Andreas Jonsson

Posted 21 January 2012 - 10:23 AM

Quickly summarized, the problem is that when I assign a value from a c++ created object (handle) to a script created one, memory is not freed properly.

The code looks like this:
cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy = pCharBV;

This does not release the memory of cBoundingVolume (I am not sure of the exact script place the memory allocation takes place but can try and find out if needed) and I get a memory leak.

However,this code works just fine:

cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy;

GetBoundingVolume is a c++ function and has this declartion:
cBoundingVolume@+ GetBoundingVolume()

I am guessing that the problem might be that I am not declaring the copy operator correctly?
Currently it looks like this:
RegisterOperator("cBoundingVolume &opAssign(const cBoundingVolume &in)", asMETHODPR(cBoundingVolume, operator =, (const cBoundingVolume &), cBoundingVolume &)  );
Do I need to do something different for it to work? (as in increasing a user count in cBoundingVolume?)

I was not sure exactly what code is needed, so just say if you need to see more in order to locate the problem!

### #3Andreas Jonsson

Posted 21 January 2012 - 09:53 AM

Quickly summarized, the problem is that when I assign a value from a c++ created object (handle) to a script created one, memory is not freed properly.

The code looks like this:
cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy = pCharBV;

This does not release the memory of cBoundingVolume (I am not sure of the exact script place the memory allocation takes place but can try and find out if needed) and I get a memory leak.

However,this code works just fine:

cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy;

GetBoundingVolume is a c++ function and has this declartion:
cBoundingVolume@+ GetBoundingVolume()

I am guessing that the problem might be that I am not declaring the copy operator correctly?
Currently it looks like this:
RegisterOperator("cBoundingVolume &opAssign(const cBoundingVolume &in)", asMETHODPR(cBoundingVolume, operator =, (const cBoundingVolume &), cBoundingVolume &)  );
Do I need to do something different for it to work? (as in increasing a user count in cBoundingVolume?)

I was not sure exactly what code is needed, so just say if you need to see more in order to locate the problem!

### #2Hardguy

Posted 12 January 2012 - 03:40 AM

Quickly summarized, the problem is that when I assign a value from a c++ created object (handle) to a script created one, memory is not freed properly.

The code looks like this:
cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy = pCharBV;

This does not release the memory of cBoundingVolume (I am not sure of the exact script place the memory allocation takes place but can try and find out if needed) and I get a memory leak.

However,this code works just fine:

cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy;

GetBoundingVolume is a c++ function and has this declartion:
cBoundingVolume@+ GetBoundingVolume()

I am guessing that the problem might be that I am not declaring the copy operator correctly?
Currently it looks like this:
RegisterOperator("cBoundingVolume &opAssign(const cBoundingVolume &in)", asMETHODPR(cBoundingVolume, operator =, (const cBoundingVolume &), cBoundingVolume &)  );
Do I need to do something different for it to work? (as in increasing a user count in cBoundingVolume?)

I was not sure exactly what code is needed, so just say if you need to see more in order to locate the problem!

### #1Hardguy

Posted 12 January 2012 - 03:36 AM

Quickly summarized, the problem is that when I assign a value from a c++ created object (handle) to a script created one, memory is not freed properly.

The code looks like this:
cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy = pCharBV;

This does not release the memory of cBoundingVolume (I am not sure of the exact script place the memory allocation takes place but can try and find out if needed) and I get a memory leak.

However,this code works just fine:

cBoundingVolume@ pCharBV = GetBoundingVolume();
cBoundingVolume bvCopy;

GetBoundingVolume is a c++ function and has this declartion:
cBoundingVolume@+ GetBoundingVolume()

I am guessing that the problem might be that I am not declaring the copy operator correctly?
Currently it looks like this:
RegisterOperator("cBoundingVolume &opAssign(const cBoundingVolume &in)", asMETHODPR(cBoundingVolume, operator =, (const aClass&), aClass&)  );
Do I need to do something different for it to work? (as in increasing a user count in cBoundingVolume?)

I was not sure exactly what code is needed, so just say if you need to see more in order to locate the problem!

PARTNERS