Skip navigation
andrey.mironov
Currently Being Moderated

Alchemy does not release ByteArray objects

Feb 3, 2011 9:52 AM

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:

screen1.png

 
Replies
  • Currently Being Moderated
    Feb 4, 2011 10:42 AM   in reply to andrey.mironov

    deleted

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 10, 2011 8:08 AM   in reply to andrey.mironov

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points