Support Staff2 Posted by Shaun Smith on 26 Jun, 2012 05:06 PM
Are you sure that GC has run? GC only runs when the Flash Player
needs more memory than is currently allocated. You may find that
the view component is destroyed quite some time after it is removed
Robotlegs cleans up view and mediator reference automatically,
so it's unlikely that the framework is holding on to your
component. Are you using a profiler to observe the component
3 Posted by Paul Cotterell on 26 Jun, 2012 06:08 PM
Thanks for the reply.
Yes, the GC has run because I am manually running it from the
If I remove the mediator mapping from the context and then
switch the state manually, it gets removed from memory when I run
It is very odd because there should be absolutely no references
keeping it in memory. What I will do is make an extremely simple
application and see if the issue is still happening with just a
basic example. If it is, then I will post the project on here and
see if other people experience it.
Support Staff6 Posted by Ondina D.F. on 28 Jun, 2012 09:12 AM
What I will do is make an extremely simple application and see
if the issue is still happening with just a basic example. If it
is, then I will post the project on here and see if other people
Are you still having problems? If the answer is yes, you’d
better attach your project or a simplified example reproducing the
issue. I’ll take a look at it.
If you solved the problem, posting your solution may help others
struggling with similar problems :)
As Shaun said: „GC only runs when the Flash Player needs
more memory than is currently allocated.“
Have you tried to force the gc: “Run Garbage Collector”
in the profiler? Or inside your code, using System.gc() twice?
There are a couple of things that could prevent your View from
In a way or another, something is holding a reference to your view
or one of its subcomponents.
A few questions for you:
Are you adding event listeners to the view or subcomponents
directly instead of using the eventMap?
Are you setting useWeakReference to false when you map the
Inside your View, are you using one of the following?
setting a styleName
using item renderers
Is it a Flex or a pure as3 project?
Is it a mobile application?
Without seeing the code, it’s hard to say if the issue
you’re encountering is caused by something listed above or if
it is something entirely different, and I would just keep
7 Posted by Paul Cotterell on 29 Jun, 2012 09:59 AM
Sorry for the delay, I have attached a small example project
that has been tested using the profiler and there is definitely no
garbage collection. I ran the garbage collector manually and the
memory didn't reduce at all.
The application attached, when run, displays an image, click the
image and it moves to a state where the image component is
you’ll have to add it through actionscript instead of mxml,
and then remove it manually when the state changes.
From Adobe’s documentation:
Controlling caching of objects created in a view state
„A change to a view state can cause Flex to create an object.
By default, after Flex creates the object, the object is cached
indefinitely, even after you switch to another view state. The item
is cached even if the destination view state excludes the
Use the itemDestructionPolicy attribute with the includeIn and
excludeFrom attributes configure Flex to completely destroy the
object when leaving a view state, including deleting it from the
cache. Typically it is more efficient to allow items to be cached
because it improves performance when switching back to the view
state that created the object, or to a view state that uses the
object. However your application might define a view state that is
rarely used, and you do not want to allocate memory for caching the
You can use the itemDestructionPolicy attribute on any object in
MXML that supports the includeIn and excludeFrom attributes. The
possible values for itemDestructionPolicy are never (default) and
The value of never specifies that the object is cached
indefinitely. A value of auto means that the object is destroyed
when leaving a view state where the object exists.“
Please let us know if setting itemDestructionPolicy="auto"
solved your problem.