From what I understand, what Ted means is that the player asks for such
and such amount of memory when it requires some, and may or may not give
it back when it doesn't need it anymore. So the worst case scenario is
that the memory consumed by the player is the maximum amount of memory
since it was loaded (the ceiling). That's the worst case scenario
however. In my personal tests in Firefox 2 when the totalMemory goes
down the memory consumption in Firefox also goes down a few seconds
later. I am talking about an app here which can take a full 100MB of
memory in a few seconds then release it in a few more seconds later
(lots of BitmapData manipulation and Loaders). I think what Ted means is
that you can't expect the garbage collector to collect when you want it
to and you can't expect that when the garbage collector is run the
memory will go down immediately, although it should eventually based on
the player's and the browser's memory allocation heuristics.
As for the effects though, I think it's possible that the instance of
the effect is still in memory after being used, but I doubt that's the
actual cause of the problem, since the effect doesn't really contain all
that much stuff in it. It's possible however that once the effect is
played it doesn't completely clean up after itself. Things to look out
for include filters, cacheAsBitmap set to true, wipe effect masks which
linger on, etc. For example, if you use have a tween from a blur filter
to set blurX from 4 to 0, you have to make sure after to set filters to
an empty array and set cacheAsBitmap to false (filters automatically set
cacheAsBitmap to true). You'd really have to look at the source code of
the actual effect you're using to see how it works internally and see if
it's doing the kind of cleanup you want it to do, and if not, then
perhaps you should try to extend the effect to do the garbage collection
yourself.
Here's my advice however: don't bother doing this unless you're in the
final stages of the application development. 10 MBs lingering about is
not going to make your app crash. I would expect that at the end your
app will have more important memory bottlenecks than this one, like
heavy use of Repeaters, too much components initialized, etc.
Patrick
coderjun a écrit :
Hello,
I was wondering if anyone has run across memory consumption issues when
using some of the eye candy in the Flex framework.
Here are a couple of examples of what I am referring to:
1. The translucent overlay on the rest of the app when using Alert.show
in modal mode. (vs. using the flag Alert.NONMODAL)
2. Using mx:WipeUp/ and mx:WipeDown/ for the inEffect and outEffect
of a component.
I've been tracking the effect of using these effects by watching Task
Manager|Mem Usage for the firefox.exe process right before and right
after these effects run. We're talking 4-10MB of memory consumed each
time these effects are run. (I know because I've done the process of
tracking with the same code and the effects turned off resulting in
300KB-1.5MB) .
My concern is that:
1. I can't programmatically (minus the unsupported tip given to us by
gskinner
http://www.gskinner .com/blog/ archives/ 2006/08/as3_ resource_
ma_2.html
http://www.gskinner.com/blog/archives/2006/08/as3_resource_ma_2.html)
force the Garbage Collector to run.
2. Since I can't force the Garbage Collector to run, the comments by Ted
Patrick on Flash Player memory management and releasing memory back to
the OS is highly concerning.
(http://tech. groups.yahoo. com/group/ flexcoders/ message/48219
http://tech.groups.yahoo.com/group/flexcoders/message/48219 |
http://tech. groups.yahoo. com/group/ flexcoders/ message/48330
http://tech.groups.yahoo.com/group/flexcoders/message/48330)
I understand that effects would consume memory to run, but I don't like
thinking that once the memory has been allocated I have no control on if
it will be given back to the Operating System.
I've tried leaving my app open all night to see if the memory allocation
would go down and it doesn't. (You would think since the effects were
long done it would) Also, the app I'm working on is one that needs to
run all day, so closing and reopening the browser is not an option.
Has anyone noticed what I've noticed or have any insight on how to use
effects without increasing the footprint so?
-Jun