Skip to main content
Participant
May 11, 2013
Question

CPU load increases over time with text box update, what is wrong here?

  • May 11, 2013
  • 1 reply
  • 715 views

I have a flash app that works fine at first but if I leave it on for about 2 hours the frame-rate drops right down and cpu usage goes up. Memory usage stays steady indefinitely.  By commenting out different functions I found the line of code that seemed to be causing the problem - it was just a timed event occuring every 1/8th of a second, updating the contents of a text box.

To make sure this was definitely the problem I made this simple script on the first frame of an empty project (it simply had a dynamic text box on the stage named "subtitles"):

var subTimer:Timer = new Timer(1,0);

subTimer.start();

subTimer.addEventListener(TimerEvent.TIMER, normalSubDate);

function normalSubDate(event:TimerEvent):void

{

subtitles.text="some text";

}

In an attempt to speed up the process the timer is set to maximum speed, frame rate to 60 (I do not know if this makes a difference).  I downloaded a performance monitor addon to give me updates on memory and frame-rate usage.  Memory stays relitively constant , however after about 5-10 minutes the frame rate begins to drop steadily until it grinds to a halt.  There must be a problem with the way I am using either the timer or the text box. 

Thanks

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 11, 2013

there's no problem with that code (unless you're repeatedly executing it).

Participant
May 11, 2013

I am running the code exactly as it appears here, and it is slowing the computer down after about 5-10 minutes.  However, I have just realised that I am using the "TLF" type of text box - for some formatting reasons that I do not really remember right now.  When I changed it to the standard "dynamic" text box there is no drop in framerate.  Perhaps I need to use one of the TLF methods to update the text rather than just re-define it constantly.

kglad
Community Expert
Community Expert
May 11, 2013

you should avoid using tlf textfields.