Skip to main content
Inspiring
January 18, 2011
Question

Memory issue

  • January 18, 2011
  • 1 reply
  • 750 views

Hello!

I have a problem with tlf using a lot of memory. Even a small test like this (see code below), takes up 47 Mb of Memory in Internet Explorer.

With a bigger test, with more text I ran into virtual memory problems (it needed more than 1 Gb of Memory).

What am I doing wrong? I'm using Flash Professional CS4 with the latest version of the textLayout.swc.

greetings, Stefan

package {
import flash.display.Sprite;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.container.ContainerController;
    import flashx.textLayout.elements.ParagraphElement;
    import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.container.ScrollPolicy;

public class Test4 extends Sprite
{
  public function Test4() {
   var tekstLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
   var cs:Sprite = new Sprite();
   var cs2:Sprite = new Sprite();
   var cs3:Sprite = new Sprite();
  
   cs2.y = 100;
   cs3.y = 200;

   addChild(cs);
   addChild(cs2);
   addChild(cs3);

   var textFlow:TextFlow = new TextFlow();
   textFlow.format = tekstLayoutFormat;

   var tekstveldController = new ContainerController(cs, 20, 40);
   tekstveldController.verticalScrollPolicy = ScrollPolicy.OFF;
   tekstveldController.horizontalScrollPolicy = ScrollPolicy.OFF;

   var tekstveldController2 = new ContainerController(cs2, 20, 40);
   tekstveldController2.verticalScrollPolicy = ScrollPolicy.OFF;
   tekstveldController2.horizontalScrollPolicy = ScrollPolicy.OFF;

   var tekstveldController3 = new ContainerController(cs3, 20, 40);
   tekstveldController3.verticalScrollPolicy = ScrollPolicy.OFF;
   tekstveldController3.horizontalScrollPolicy = ScrollPolicy.OFF;

   var paragraphElement = new ParagraphElement();
   var spanElement = new SpanElement();
   spanElement.text = "aaabbbcccdddeeefffggg";
   spanElement.fontSize = 10;
   paragraphElement.addChild(spanElement);

   textFlow.flowComposer.addController(tekstveldController);
   textFlow.flowComposer.addControllerAt(tekstveldController2, 1);
   textFlow.flowComposer.addControllerAt(tekstveldController3, 1);
  
   textFlow.addChild(paragraphElement);
   textFlow.flowComposer.updateAllControllers();
  
   trace (textFlow.flowComposer.findControllerIndexAtPosition(textFlow.getText().length-1));
   trace (textFlow.getText());
  }
}
}

This topic has been closed for replies.

1 reply

January 20, 2011

How much more text do you need to add to get to a gigabyte's memory usage? There will be an initial bump in memory usage even for a small amount of text, as the textLayout.swc is larger than most swcs you might encounter. But adding more text should not increase memory usage that much over the initial cost of using TLF.

Inspiring
January 20, 2011

Hello Alan,

Thank you for your answer!

I've made a small test to add some text and see how much extra memory was needed and indeed it is very little...

I think somewhere in my program i have made a mistake with memory management...

Thanks!