Maximum .PRG file size error

I am trying to recompile one Application from github from one watch model to another. When I build it I get this error

ERROR: PRG generated exceeds the memory limit of app type 'watch-app' for device id 'instinct2x': 218282 bytes.

What does it exactly mean? Is it max file size of prg file 218282 bytes or it is bigger than maximum allowed by 218282 bytes or what?

When I build it I get 363980 bytes prg file.

Can I find somewhere the list of max oprg files for each watch?

Also, how can I decrease the size of prg file? Maybe change SDK version or some compiler option?

  • Yes, I saw this one. But I thought it is memory limit (RAM), not the prg file size limit. Or eventually, the whole prg file must be loaded into memory?
    Also, I found an interesting fact. If I build it for instinct 3, the file is 73000 bytes, but for instinct 2 it becomes 363980, almost 5 times bigger. Why is there such a big difference?

  • the whole prg file must be loaded into memory?

    Yes, the whole PRG file (except for resources) has to be loaded into app memory. Resources are at the end, so they can be excluded (and loaded on demand).

  • Not true for a debug build, where the debug info doesn't get loaded.  If you look at the prg in bin, that's a debug build, it's much larger than a release build due to all the debug info

    With an app I'm working on the prg in bin is 95k (debug build), while if I build for device (release build) it's 9k, while what I see with view memory in the sim for peak memory is 7.8k,  

  • Thank you for all your replies, but numbers are still not matching. What I have now.
    Builidng release version for instinct2.
    Error message: ERROR: PRG generated exceeds the memory limit of app type 'watch-app' for device id 'instinct2x': 212078 bytes.
    PRG file size: 233324 bytes
    Memory on instinct 2: 98304 (based on this link https://github.com/flocsy/garmin-dev-tools/blob/main/csv/device2memory-watchApp.csv)
    All resources (png images): 9646 bytes.

    now if I do like this:

    233324-9646=223678

    or like this

    233324-98304=135020

    nothing is matching 212078 bytes from error message.

    Anyway, I understand the approximate reason for the error. The main question for now is how to reduce PRG file size? Looks like I need to make it less than 98304 bytes.

    I tried 

    project.optimization = 2z
    or
    project.optimization = 2pz
    in my monkey.jungle config file, but it does not make any difference. Not even 1 byte less. If I choose older SDK (7.3.1 instead of 8.2.1) then I get 
    233132 bytes (192 bytes less) but it is not enough.
    Funny thing, that if I build it for instinct, then PRG file size is 73000 bytes.
  • Be careful with those numbers as the available memory for an app is actually less than what you see there.  the CIQ VM takes memory that's not available to your app 

    You can see what's actually available on the bottom line of the sim..


    For all devices with CIQ 3.0 or greater and all app types, this is the case.  So on an I2 with a data field, you may see it can be 32k, but in reality you can only use 28k

    Also the size of the prg file doesn't always show the memory requirement for the app.

    For example, if your app has

    arr=new [10000];

    that doesn't change the size of the prg file much, but can really change the amount of memory required.  You get the memory error at run time and not compile time, correct?

  • You get the memory error at run time and not compile time, correct?

    Isn't it obvious that the error message refers to the PRG file size and that it's happening at compile time?

    I am trying to recompile one Application from github from one watch model to another. When I build it I get this error

    ERROR: PRG generated exceeds the memory limit of app type 'watch-app' for device id 'instinct2x': 218282 bytes.

    --

    Builidng release version for instinct2.
    Error message: ERROR: PRG generated exceeds the memory limit of app type 'watch-app' for device id 'instinct2x': 212078 bytes.

  • All resources (png images): 9646 bytes.
    nothing is matching 212078 bytes from error message.

    If your resources are PNG images and they take up 9646 bytes on your dev machine, it doesn't mean that that they take up the exact same amount of space in the PRG.

    - the png files could be converted to bitmap by the resource compiler, which would probably make them bigger. (older devices only support bitmaps, and even newer devices require you to explictly set the packing format if you want anything other than bitmap)

    - there also could be some additional overhead for resources that's present in the PRG

    If you are interested in digging into the contents of your PRG file, you could try this PRG parser: https://github.com/pzl/ciqdb 

  • People have built huge prg files without this error.

    By any chance are you using type checking?  What level?  You may be getting the error from that.

    As a quick test, turn type checking off by adding

    project.typecheck = 0

    to your monkey.jungle file and try building again.

    Anything change?

  • I already have project.typecheck = 0.