This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to estimate RAM requirements?

I have a basic prototype program running in Arm Development Studio. This needs to execute in a system with very limited resources.  How should I estimate the total RAM needed to run it?

It is a C++ program. How can I specify the maximum heap and stack sizes?

Best regards

David

Parents
  • Hi David

    To estimate stack usage, see
    https://developer.arm.com/documentation/100748/0616/Writing-Optimized-Code/Stack-use-in-C-and-C--

    Heap usage can be difficult to estimate, because it depends on run-time use of malloc/free (or new/delete for C++), though a program can at least test the return result of e.g. malloc() to see whether the heap is exhausted.

    Placing the stack and heap is best done with a scatter file, see
    https://developer.arm.com/documentation/100748/0616/Mapping-Code-and-Data-to-the-Target/Placing-the-stack-and-heap-with-a-scatter-file

    Take a look at the scatter file "scatter.scat" in the "startup_Armv8-Ax1_AC6" example (for Cortex-A53) or in the startup_Cortex-M7_AC6 example (for Cortex-M7).

    You will also need to allocate space for the variables in the program, for both RW/.data and ZI/.bss.  The linker's output from its "--info=totals" switch can help here, for example:

    ==============================================================================
    
    Image component sizes
    
    
          Code (inc. data)   RO Data    RW Data    ZI Data      Debug   
    
          1548        352        148          0      11688       7611   Object Totals
             0          0         32          0       8192          0   (incl. Generated)
            62         16          3          0          0          0   (incl. Padding)
          9372        458        480         20        576       7340   Library Totals
            28          4          3          0          0          0   (incl. Padding)
    
    ==============================================================================
    
    
          Code (inc. data)   RO Data    RW Data    ZI Data      Debug   
    
         10920        810        628         20      12264      10931   Grand Totals
         10920        810        628         20      12264      10931   ELF Image Totals
         10920        810        628         20          0          0   ROM Totals
    
    ==============================================================================
    
        Total RO  Size (Code + RO Data)                11548 (  11.28kB)
        Total RW  Size (RW Data + ZI Data)             12284 (  12.00kB)
        Total ROM Size (Code + RO Data + RW Data)      11568 (  11.30kB)
    
    ==============================================================================
    


    Hope this helps

    Stephen



Reply
  • Hi David

    To estimate stack usage, see
    https://developer.arm.com/documentation/100748/0616/Writing-Optimized-Code/Stack-use-in-C-and-C--

    Heap usage can be difficult to estimate, because it depends on run-time use of malloc/free (or new/delete for C++), though a program can at least test the return result of e.g. malloc() to see whether the heap is exhausted.

    Placing the stack and heap is best done with a scatter file, see
    https://developer.arm.com/documentation/100748/0616/Mapping-Code-and-Data-to-the-Target/Placing-the-stack-and-heap-with-a-scatter-file

    Take a look at the scatter file "scatter.scat" in the "startup_Armv8-Ax1_AC6" example (for Cortex-A53) or in the startup_Cortex-M7_AC6 example (for Cortex-M7).

    You will also need to allocate space for the variables in the program, for both RW/.data and ZI/.bss.  The linker's output from its "--info=totals" switch can help here, for example:

    ==============================================================================
    
    Image component sizes
    
    
          Code (inc. data)   RO Data    RW Data    ZI Data      Debug   
    
          1548        352        148          0      11688       7611   Object Totals
             0          0         32          0       8192          0   (incl. Generated)
            62         16          3          0          0          0   (incl. Padding)
          9372        458        480         20        576       7340   Library Totals
            28          4          3          0          0          0   (incl. Padding)
    
    ==============================================================================
    
    
          Code (inc. data)   RO Data    RW Data    ZI Data      Debug   
    
         10920        810        628         20      12264      10931   Grand Totals
         10920        810        628         20      12264      10931   ELF Image Totals
         10920        810        628         20          0          0   ROM Totals
    
    ==============================================================================
    
        Total RO  Size (Code + RO Data)                11548 (  11.28kB)
        Total RW  Size (RW Data + ZI Data)             12284 (  12.00kB)
        Total ROM Size (Code + RO Data + RW Data)      11568 (  11.30kB)
    
    ==============================================================================
    


    Hope this helps

    Stephen



Children