Acknowledged

Peak memory tracing crashes simulator

The peak memory usage feature in the simulator "Active Memory" cannot be enabled consistently. I've only managed to do it a few times. Clicking the checkbox does not enable the buttons except in rare circumstances, which I cannot reproduce except by luck. The few times I have been able to click the peak stack trace button, a dialog box appears and flashes for a little while, then the simulator crashes and just disappears. Has this "feature" ever worked, and if so, how to get it working properly?

  • I can set breakpoints and get snapshots of memory usage but I could do that anyway with getsystemstats and println. Still, I get things like this:

    Hit breakpoint 1, onUpdate () at AnnulusWatch.mc:38
    Hit breakpoint 2, onUpdate () at AnnulusWatch.mc:39
    Hit breakpoint 3, onUpdate () at AnnulusWatch.mc:40
    Hit breakpoint 1, onUpdate () at AnnulusWatch.mc:38
    Hit breakpoint 2, onUpdate () at AnnulusWatch.mc:39
    Kill app for resume the app
    Failed to terminate app: Timeout
    Hit breakpoint 3, onUpdate () at AnnulusWatch.mc:40
    Kill app for get stack backtrace
    Failed to terminate app: Timeout
    [Ljava.lang.StackTraceElement;@19dad439
    

    And the peak stack trace never shows anything other than this:

    If peak memory usage is anything other than broken, I can't tell.

  • As a test, I used "Moneyc: New project", to create a simple WF without settings.  You can't get much simpler than this.

    Then to make it interesting, I commented out both onLayout and onUpdate.

    You still see the peak at startup. 

    It's using 5.8K with a peak of 8.0k with an instinct2 in the sim.

    It's using 5.5k with a peak of 7.6k with a fr265.

    You really can't do anything in the code to reduce this.  Turning on 

    project.optimization = 2
    did nothing 
  • It's not leaks I'm worried about, I'm trying to optimize memory usage so I have more room to implement certain features. If I can find the actual peak maybe I can rewrite it and move on to chasing the next one until I get to one I can't fix.

  • I hacked one of my watch faces so that each time onUpdate is called, it uses more memory, and sure enough, after a bit, the buttons weren't grayed out.  Let it run a while longer, and the app ran out of memory.

    Like I said you'll see a peak when an app starts. (same watch face) I see about 2k difference.

    If the buttons stay grayed, that's good, as your peak isn't increasing - no leaks

  • That's not really helpful for me. If I do something to create a new fake peak to activate the buttons, I will no longer be able to detect the peak that I am actually looking for. It's a watch face, if it is increasing after it starts then it's leaking. I have a consistent 2-3k difference between used and peak depending on the device. Once it's peaked which is sometime before I can open the dialog it doesn't change after that. Based on some debug statements it's after "onLayout" so it's somewhere in one of the rabbit holes in onUpdate.