Free memory in simulator vs real device difference – which to trust?

In my data field I have been logging free memory in both sim and on real devices using System.println(System.getSystemStats().freeMemory). To figure out where in the code I max out and then try to optimize dynamic loading and code those places, e.g. in connection with load of custom fonts during the run/activity.

I have though noticed some rather big differences between the sim and real devices – for several devices in fact: fr645, epix2, Venu2. E.g. in fr645 in onUpdate() call I get ~500 more bytes free in the real device and in compute() I get ~1000 bytes more free. And, I would really like to use that extra free memory in real word ….

I kind’a assume that it’s the real device data I can trust – or can I?

  • I have been experimenting with settings:

    I again allocated more and more memory, until the point where the data field crashes in sim. Then allocate further 800 bytes, and download to device. No crashes whatsoever on real device, also not when I update the settings. All of this pre-run.

    Actually: in my App, I load custom fonts first once the activity starts. So I have plenty of free space pre-running where settings are transferred. 

    For fun, I also tried same experiment and send new settings _after_ I started the activity and hence max memory load due to custom fonts. An unrealistic use case I would argue. Interestingly, also seem Garmin is not supporting this. Because all settings got cleared to default if I tried it. And, a strange \GARMIN\E_FILE.ERR file got generated, not the usual CIQ_LOG file when I finally managed to make the App crash due to memory running out. Again, not a problem in practise, just kind'a interesting.  

    Anyhow: My conclusion is that in my case, for my specific data field App with max peak during running, I should be just fine pushing beyond where I run out of memory in peak load in simulator. Probably not the full 800+ bytes, since the diff in Sim vs real device seem to vary across devices, but 400+ bytes seem fine. Let me know if anyone have tried this and concluded differently!