Hitting memory limit

Can somebody explain the memory usage?

I need to reduce my memory usage, so I'm wondering why is <code> using so much memory?

Does that mean, that all strings and images are part of it event when they are not loaded, they consume memory space?

  • Try with release build. Debug builds have lot of stuff that isn't there in release

  • Code is so big because of how you wrote the app.  Here for example is a watchface of mine

    Notice code is only 3236, and when the watchface runs, it's only about 12k

    Start commenting out sections of code and see what's causing this for you.

  • yeah - found out, even unused code counts into memory. seems to be due the fact of dynamic linking the whole code is loaded into memory. so i need to exclude the unused code from compilation.

  • You only want to include code your app actually uses.  When an app is compiled, everything by default is part of "code" even if you don't use it, and all of "code" gets loaded into memory.

  • I am joining this thread because I am also experiencing memory issues with many of my data fields. However, I am encountering problems with “stack overflow.” I assume this issue is also due to the amount of code, although I am not programming any nested functions. The “available memory” is usually well below the possible maximum.
    I‘m wondering what I could do better…

  • When a function is called the parameters are put on the stack.  In CIQ, the stack space is limited and doesn't grow  You can run into this if you try to pass too many parameters to a function, or if you have something like function a calling function b, which calls function c, which calls function d etc.

  • I've seen this during debugging a few times. I think it's not that there's no more free heap memory, but the stack. There are other ways to fill the stack, not only with recursion. When you enter a function then everything you passed (that means the references of objects, not the objects themselves) and every local variable you declare in the function are out on the stack.