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.

Parents
  • 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.

Reply Children
No Data
Related