cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating the memory requirements for screens

ananya
Associate II

Hello,

I want to calculate RAM requirement for one screen with some widgets and images.How can this be done.

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @ananya​,

Here's a way of calculating the size of both worst case View (including widgets) + Presenter or just the size for any screen you want. Then you have some memory for OS / Heap potentially.

int main(int argc, char** argv)
{
   ....
    // Print out size information
    printf("*** Memory usage: ***\r\n");
    printf("Largest view      %lu\r\n", (long unsigned int) sizeof(FrontendHeap::MaxViewType));
    printf("Largest presenter %lu\r\n", (long unsigned int) sizeof(FrontendHeap::MaxPresenterType));
    printf("Datamodel         %lu\r\n", (long unsigned int) sizeof(Model));
    printf("Total:            %lu\r\n", (long unsigned int) sizeof(FrontendHeap));
 
   printf("*** Screens: ***\r\n");
    printf("MyView%lu\r\n", (long unsigned int) sizeof(MyView));
...
}

This code can be run in the simulator.cpp main() method.

/Martin

View solution in original post

5 REPLIES 5
Martin KJELDSEN
Chief III

Hi @ananya​,

Here's a way of calculating the size of both worst case View (including widgets) + Presenter or just the size for any screen you want. Then you have some memory for OS / Heap potentially.

int main(int argc, char** argv)
{
   ....
    // Print out size information
    printf("*** Memory usage: ***\r\n");
    printf("Largest view      %lu\r\n", (long unsigned int) sizeof(FrontendHeap::MaxViewType));
    printf("Largest presenter %lu\r\n", (long unsigned int) sizeof(FrontendHeap::MaxPresenterType));
    printf("Datamodel         %lu\r\n", (long unsigned int) sizeof(Model));
    printf("Total:            %lu\r\n", (long unsigned int) sizeof(FrontendHeap));
 
   printf("*** Screens: ***\r\n");
    printf("MyView%lu\r\n", (long unsigned int) sizeof(MyView));
...
}

This code can be run in the simulator.cpp main() method.

/Martin

When I tried with the above in the main function, I got the following error in IAR.

Error[Pe070]: incomplete type is not allowed

Error[Pe070]: incomplete type is not allowed  

Error[Pe070]: incomplete type is not allowed

You'd do this for the simulator main.cpp only. The simulator application will output the sizes in a terminal. You won't get anything out of printf in IAR.

/Martin

ananya
Associate II

Hi @Martin KJELDSEN​ ,

When we want to calculate the RAM memory required for GUI,should we consider sum of all the screens' memory requirement?

How should it be calculated?

Martin,

Is there a strategy for managing memory for late bound widgets?

I have an application that I would like to allow my users to define their screens by allowing them to load/drop widgets dynamically at runtime. Those dynamically added widgets will then be stored on the SD Card as a file for the next running/startup.

So, basically the screens (pages of a swipe container) will be empty at compile time when TouchGFX tries to decide my Heap size it will be less than needed. I'm guessing I will adjust that for a reasonable heap size, then readjust based on how many widgets the customer drops on the screens?