Optimize memory usage

Hi there,

I recently adquired a Forerunner 230, and being a developer myself, I found Connect IQ very appealing. I downloaded the SDK and I were soon sideloading my own fields (in fact I am developing a big field that shows several things in it).

The problem I've got is that I run out of memory. I understand that fields have a limited memory, but how much limited they are? For instance, my app ran out of memory in the simulator with an array of 64 element, but worked with an array of 32. I just only want to store the heart rate history, so I need just 64 bytes... even my first Amstrad CPC 64Kb could handle that so I am sure I am missing something.

So, what are the memory limits for developing a field? Is there a limit for code? Is there a limit for data? Are there some guidelines on how optimize memory usage? I mean... I am no expert with Monkey C...

I apologize if this has been asked before or this info is readily available anywhere... I tried to find answers to that but I couldn't.

Regards,
Kurt.-
  • on a 230, data fields are limited to 16k - program and data space combined.

    The bottom line in the simulator gives you an idea of where you are at.
  • Hi Jim,

    Thanks for the answer. Yes, I saw that and 16 Kb is plenty of space for what I am doing, so an array of 64 elements should not be a problem.

    Today I updated to the las SDK from the previous one (1.2.2) and now it works in the simulator with an array of 64 elements. I guess that something has been fixed in the last SDK. This is not the first inconsistence I've found in the simulator, but obviously it is a young platform, and new versions are actively developed, so it will get even better over time...

    Regards,
    Kurt.-

    PS: If Garmin would add to Activity.Info current lap timer and distance, it would be awesome!
  • I also had this kind of worries.

    There are a few tips:
    - Minimize code size (factorization, removing dead code, ...)
    - String concatenation: prefer the + operator to Lang.format
    - Delete unused variables
    - Reduce custom fonts

    the memory usage is different between the simulator and the watch. Show remaining memory still consumes some memory but it is very useful to see the consumption in real use.
  • Hye, 

    To save memory, is it better to have only one custom font with all letters or have a ressource folder by language ?

    Do you have some. Other tips to save memory ? 

  • There are some good memory tips in this thread: https://forums.garmin.com/developer/connect-iq/f/discussion/6000/preserving-memory-in-monkey-c/39909#39909

    One thing I've found useful recently to save memory with fonts is if you are handling characters with diacritics (like accent, cedilla, etc) then don't have your font include every character with the different diacritics you require. Instead just have all the base letters from A-Z and then a single character for each diacritic with no attached letter. Then when you need to draw a letter with a diacritic you draw the base letter followed by the diacritic on top in a separate pass.

  • Hum I have an other problem, I put a custom font with cyrillic in Resources-rus but it doesn't seem to work doing that ...Did I miss something for this?

    Tjanks for the lonk, I've already seen it and tried to apply the advices.