ListItemRenderer.as adds and removes its icon in commitProperties.  If it is 
the same 3 icons, and they are small, they should be embedded and then you 
don't need the Image class and will save lots of memory that way too.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: [email protected] [mailto:[email protected]] On Behalf 
Of Dmitri Girski
Sent: Friday, February 13, 2009 7:21 PM
To: [email protected]
Subject: [flexcoders] Memory consumption. Part 2. ItemRenderers


Hi Everybody,

I have identified the memory consumption problem within the custom
ItemRenderer. This IR is derived from UIComponent and besides other
elements has 3 Image members to display 3 possible icons.
The grid has around 200 elements, so 200 IRs are created at the
startup. Each IR creates 3 Images in createChildren() method with
source = null. Source is set in the commitProperties() method, when we
know the data. In reality only 10-15 IRs are displaying icons, the
rest are just waisting the space (600 instances of Image consumes
aroung 700Kb according to Profiler).

My question is how can I improve the efficiency of this IR?

Is this possible to create Image instances on demand, not in the
createChildren() method?

I tried to create and destroy Images in commitProperties() according
to data, but then I bumped into the problem that updateDisplayList()
for the IR could be called with inconsistent data. I.e. data says that
we need icons, but the the Image objects is null, they have not been
created yet by commitProperties()/set data() for this instance.
Is this a recycling feature that the order of
commitProperties()/updateDIsplayList() are not guaranteed? Or I have
overseen something?

Thanks in advance!

Regards,
Dmitri.

Reply via email to