Possible memory leak

Software: Away3D 4.x

Avatar
Alexander Seifert, Moderator
Posted: 17 August 2012 08:25 AM   Total Posts: 129

Hey guys,

I’m taking a look at Gold now and see alpha regression fix. However, in MaterialBase line 159 & 159:

_passes[_numPasses-1] 

Doesn’t that cause a memory leak?
Instead:

_passes[uint(_numPasses-1)

? Or has that finally been fixed by Adobe and it is save to use calculations in Array/Vector accessions without explicitly typecasting to (unsigned) integer?

Thanks!
Alex

 Signature 
signature_image

http://www.deltastrike.org

   

Richard Olsson, Administrator
Posted: 17 August 2012 09:18 AM   Total Posts: 1192   [ # 1 ]

For reference, this has been filed as a bug and the discussion continues there. https://github.com/away3d/away3d-core-fp11/issues/389

   

Avatar
Alexander Seifert, Moderator
Posted: 17 August 2012 10:40 PM   Total Posts: 129   [ # 2 ]

Thank you, Richard.

For everyone else, maybe a little more info, maybe there’s something to learn =) So here we go:

A year ago we discovered that using binary numeric operations in array/vector accessors caused a small but noticeable memory leak, regardless if only reading from the array/vector or assigning a value.
E.g.
array[(i += 2) % 3]
Someone at Adobe, I believe, commented that all numbers in AS3, even (unsigned) integers, were backed by a 64-bit wide float, which meant that even integers in numeric expression were internally converted to Number (float) before any calculations and were converted back to their original type afterwards. In the process, some memory was leaked, but only in array/vector accessors.

This was discovered only with high-fps update loops doing enough of such accessions to actually cause the Garbage Collector to throw in some extra shifts, which could be clearly be felt in a stuttering frame rate.
Only by chance it was discovered that an explicit typecast to int or uint, e.g.
array[uint((i += 2) % 3)]
did not cause any memory to leak.

As mentioned, this was already a year ago and my memory has seen better days raspberry So don’t nail me on any details I may have gotten wrong wink Back then it definitely was an issue which caused quite some code review. And I never noticed whether Adobe has taken care of that ever since.

Cheers!
Alex

 Signature 
signature_image

http://www.deltastrike.org

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X