I'm trying to use libjpeg encoder to encode bitmap to jpeg and notice, that original data never releases from memory. After some testing I found tha alchemy hold references to them. Is that a bug or am I doing something wrong?
Here is my ActionScript code:
protected function doSomethingButton_clickHandler(event:MouseEvent):void
{
var data:ByteArray = new ByteArray();
for (var i:int = 0; i < 1000; i++) {
data.writeInt(Math.round(10000 * Math.random()));
}
Demo.doSomething(data); // This is an alchemy class
}
And here is my *.gg file:
import flash.utils.ByteArray;
public function doSomething(data:ByteArray):void
{
}
The functiion does nothing! And profiler shows that all of this ByteArray objects stay in memory:
I'd like to know if the AS3_Release(data) is a valid thing to do, or not.
It's been a while, but the last time I profiled for a leak in alchemy, it appears that the passed-in parameters (to an API compiled with gluegen) are kept in alchemy in some sort of weak reference Dictionary. These get cleaned up when alchemy decides to scan for cleanup - not when you want them gone.
So, passing-in objects that hold lots of memory (like a byte array) is a bad thing. I had thousands of Rectangle objects being held by alchemy (and they do not get cleaned by a manual garbage collect in the profiler), but sure enough, they eventually go away.
I didn't think that the AS3_Release on input parameters was a valid thing to do, but perhaps it is, provided the object isn't referenced anywhere else in alchemy for other valid reasons? I wouldn't want things to blow up.
North America
Europe, Middle East and Africa
Asia Pacific