You've got 4,000 things all moving around at once? Are all 4,000 of those
actually visible? 4,000 UI components seems like a lot for any layout
manager to have to deal with. I'd try to focus on figuring out how to reduce
the number of UIComponents before I worried about how much memory each one
is taking up. I may be totally off base, but I can't imagine a scenario
where you want 4,000 images all on the screen at the same time.

And if you do really need to load 4,000 swfs all at the same time then you
probably want something that's lighter than custom UIComponent classes,
which would keep those 4,000 objects out of the normal
invalidation/validation cycles of the display list.

Doug

On Wed, Oct 15, 2008 at 1:34 PM, Michael Schmalle
<[EMAIL PROTECTED]>wrote:

>   A side note,
> You are doing some very expensive leg work in the 'content' setter.
>
> You need to break that out into commitProperties() and updateDisplayList().
>
> You would get a huge performance increase for sure.
>
> As far as the memory, doesn't look to weird, event listeners without weak
> references can make thing hang around as well.
>
> Mike
>
>
> On Wed, Oct 15, 2008 at 3:08 PM, flexaustin <[EMAIL PROTECTED]> wrote:
>
>>   So I have this base component, that when running profiler, says its
>> eating up tons of memory. I have about 4000 of these at one time in
>> my Flex app (see component code below). This base component is
>> extended by two other components, which are then extended by two more
>> components each so 3 or 4 levels above this base component.
>>
>> 1. My first question is does the profiler just point to the base class
>> or are there actually 4000 of these being created outside of their
>> extended children?
>>
>> 2. My 2nd question is is their anything wrong with the code below? Why
>> is it eatin memory? The parameter "content" when pulled in is a swf
>> file (icon) that is 5kb each so 5kb * 4000... you get the math.
>>
>> When I run this progam the CarouselImage's are using up 30% to 35% of
>> my apps memory usage. And my app is eating up 725,000kb of mem usage,
>> thus crashing my pretty decent computer.
>>
>> // ----------- BEGIN CODE --------------------------------------
>> package com.mysite.views.components
>> {
>>
>> import flash.display.DisplayObject;
>> import flash.system.ApplicationDomain;
>>
>> import mx.core.UIComponent;
>> import mx.events.ResizeEvent;
>>
>> public class CarouselImage extends UIComponent
>> {
>> // Content
>> private var _content:DisplayObject;
>> private var _contentWidth:Number;
>> private var _contentHeight:Number;
>>
>> public function CarouselImage(content:*=null)
>> {
>> super();
>>
>> // Set content
>> this.content = content;
>> }
>>
>> // Properties
>> [Inspectable]
>> public function get content():DisplayObject
>> {
>> return _content;
>> }
>>
>> public function set content(value:*):void
>> {
>> if (_content != null)
>> {
>> removeChild(_content)
>> removeEventListener(ResizeEvent.RESIZE, handleResize);
>> }
>>
>> if (value is String)
>> {
>> try
>> {
>> value = ApplicationDomain.currentDomain.getDefinition(value);
>> }
>> catch (error:*)
>> {
>> // Do nothing
>> }
>> }
>>
>> if (value is Class)
>> value = new value();
>>
>> _content = value as DisplayObject;
>>
>> if (_content != null)
>> {
>> _contentWidth = _content.width;
>> _contentHeight = _content.height;
>>
>> addChild(_content);
>> addEventListener(ResizeEvent.RESIZE, handleResize);
>>
>> scaleContent();
>> }
>>
>> this.invalidateDisplayList();
>> this.invalidateProperties();
>> this.invalidateSize();
>> }
>>
>> public function get contentWidth():Number
>> {
>> return _contentWidth;
>> }
>>
>> public function get contentHeight():Number
>> {
>> return _contentHeight;
>> }
>>
>> // Measure and draw
>> private function scaleContent():void
>> {
>> if (_content != null && width > 0 && height > 0)
>> {
>> // Width
>> _content.scaleX = width / contentWidth;
>> // Center the image
>> _content.x = (width - (contentWidth * _content.scaleX)) * 0.5;
>>
>> // Height
>> _content.scaleY = height / contentHeight;
>> // Center the image
>> _content.y = (height - (contentHeight * _content.scaleY)) * 0.5;
>> }
>> }
>>
>> // Event handlers
>> private function handleResize(event:ResizeEvent):void
>> {
>> scaleContent();
>> this.invalidateDisplayList();
>> this.invalidateProperties();
>> this.invalidateSize();
>> }
>>
>> }
>> }
>> // ----------------- END CODE ------------------------------------
>>
>>
>
>
> --
> Teoti Graphix, LLC
> http://www.teotigraphix.com
>
> Teoti Graphix Blog
> http://www.blog.teotigraphix.com
>
> You can find more by solving the problem then by 'asking the question'.
>  
>

Reply via email to