This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to monitor flash and RAM usage after compilation?

Is there a window in Keil uVision available to monitor how much flash and RAM I've consumed? I'm not seeing anything in the build output and am not sure where else to look.

  • Hi,

    Have you tried looking at the map file that is generated when you compile your code? It is located in the subfolder "arm_build" in your project folder.

    Leo

  • That is helpful. I find at the bottom total RO, RW and ROM sizes. I'm not sure how that translates to flash/program memory and RAM/data memory though. There is also no way to quickly see this via the IDE? It's a bit of work to navigate to the file, scroll to the bottom, then check after each compilation.

  • I don't know if there is another way to view those information in the IDE. To view the information, I usually just open and view the map file in the IDE itself.

    Leo

  • The total RAM consumption is:

    ZI-data + RW-data
    

    The total flash consumption is:

    Code + RO-data + RW-data
    

    These values should be listed when you compile your project (atleast in Keil, use 'arm-none-eabi-size myapplication.out' for GCC) or located in the .map file generated by the compiler/linker.

    Why is RW-data listed in RAM and code? This is because this section holds the non-zero initialized values. for instance:

    static int g_test = 0xFF1234FF;
    

    This will consume 4 bytes of RAM, and 4 bytes of flash to store it's initial value (0xFF1234FF).

    More details about RAM usage:

    The total RAM consumption also holds the application stack for auto-variables, which variables inside a scope, such as int func(){int a; int b;}, where 'a' and 'b' here are auto-variables. The default stack_size set in your arm_startup.s file is set to 2048 bytes.

    If the stack grows outside it's area (2048 bytes in this case), meaning that your auto-variables in scope is greater than the stack_size set, you will run into a stack overflow. if you google "stack usage monitoring" or similar you'll find methods for evaluating the stack usage for a given application. Note that the overall stack usage must be evaluated run-time, with the application running in all corner-cases.

    Sorry if I've confused you, Håkon

  • This is helpful in teaching me more, thank you. I was hoping for kind of usage gauage on the Keil GUI or a simpler way to just keep that in mind after each build. I've enjoyed MPLABX's data memory and program memory usage gauges in the past.

Related