Skip navigation
Currently Being Moderated

Urgent: Serious lag related to System.privateMemory and possibly garbage collection

Feb 25, 2012 11:13 AM

Tags: #ios #lag #performance #garbage_collect



I'm porting a Flashgame to iOS. I already cpu-, render- and memory-optimized it and it runs really smooth on the device, EXCEPT for some very serious lags that always happen at the same time in the first level.


Here is a video showing the lags (sorry for bad quality, but the lags are very apparent):


I keep track of memory consumption over the runtime of the game, here is a screenshot:



(click for higher resolution)


color coding:

the blue line shows System.totalMemory

the green line shows System.freeMemory

the yellow line shows System.privateMemory

all lines are scaled in respect to their Peak value

the red lines show lags (black meaning the frame runs at the desired framerate and the red is something like reddishness = (1.0-fps/Stage.frameRate)*red), but only two of those lags are really relevant (marked in the screenshot).


at one of the lags, there is a very large drop in System.totalMemory, but only for a very short time (this spike always occurs, but randomly either on the first or on the second lag. i never observed it to happen on both lags and i never observed it to happen on neither lag)


The firing of the garbage collector is also visible in the graphic, but it does not seem to cause any lag - however it affects only System.totalMemory as well as System.freeMemory. System.privateMemory seems to be unaffected.


Manually calling the garbagecollector also doesn't solve the problem. in the following screenshot i make manual calls to System.gc() (visible as cyan collored lines) - and again it affects only System.totalMemory and System.freeMemory, but not System.privateMemory:



(click for higher resolution)


I need help in tracking down the problem. Does anyone have a good understanding in what exactly System.privateMemory is and what could cause the significant drop on the lags? also It's weird that the drop of System.privateMemory is always apparent on only one of the two lags, but never on both.



Any help on that is highly apreciated!





The lags appear to happen at regular time intervals. if i make my character run at half the speed, there will be twice as many lag during level 1 and the memory usage will look like this:


  • Currently Being Moderated
    Feb 29, 2012 5:46 PM   in reply to greengnu

    Sorry, I don't have any real insight, but I wonder if it has to do with sending graphics to the GPU/texture memory?  This has caused bottlenecks in the past for us.  However, in your case running the character at half the speed should not have caused more lags if this was the case.


    Have you also tried compiling with a different version of the AIR SDK?  We just recently had a memory problem (random crashes) that was solved simply by using v3.1 (we were on 2.7), though for you I wonder if trying an older version (like 2.7) may resolve it?

    Mark as:
  • Currently Being Moderated
    Mar 1, 2012 12:37 AM   in reply to greengnu

    Great! A lot of work, but glad it is going well. Performance still ok with all the manual calculation?

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points