Runtime allocation to reduce RAM


How to use runtime allocate check box in GUIX and how it is related in the code?

I checked the Runtime allocation for a window which i have initialed in code after building the code it shows error as this is not initialized wherever i am using "CommonWidgetCreate" function. but RAM size is reduced.

I am using multiple handler, when i switch from one to other i want to deallocate the memory of the other mode's memory. using malloc and calloc function.(i need to do this for each windows i created for last handler)

How do i use malloc and calloc for creating window?

below are the image that shows the widget name and the error

  • Hello, 

    Kindly provide the whole line code? The screenshot seems to be cut-off. 
    In parallel, have you also tried to implement this suggestion from a previous thread: GUIX: How to reduce RAM consumption?

    Hope this helps you.


    If this response, or one provided by another user, answers your question, please verify the answer. Thank you!
    Renesas Engineering Community Moderators

  • Hi, dear Ivok.

    Here are the steps you can follow to utilize the dynamic memory allocation for your graphic objects: 

    -Azure GUIX is written independent of the RTOS or specific technology so that you can specify your desired memory allocation mechanism. There's a function In Azure GUIX 'gx_system_memory_allocator_set()' which you can pass your dynamic memory allocation/deallocation function pointers to it. Here you can define malloc and calloc to assign the needed memory, but it's a good practice to not use those functions in ThreadX because it might cause memory fragmentation and isn't thread-safe. it's better to use a memory pool in threadX. 

    For more information about the memory pools see this link and search for 'memory pool'. 

    Now, create the memory pool and write the allocate/deallocate functions, memory pool size is dependent on your application needs and will occupy a constant section of RAM then GUIX will use this section for dynamic allocation using the provided function pointers. 

    include 'tx_api.h' in your program to utilize the memory pool feature: 


    Then initialize the memory pool and set the function pointer

    Now The GUIX memory allocation is set.

    About the 'runtime allocate' check box in GUIX studio and its relation with code, when the checkbox is checked, 'GX_WIDGET_STYLE_DYNAMICALLY_ALLOCATED' will be defined for that object, you can check it in resources files. this attribute will specify the runtime allocation feature when the object is created or destroyed the memory will be allocated, and freed automatically by the GUIX. 


    As you can see you need to pass the parameters differently than a static object. and will not have a control handle like static ones.

    I recommend checking out this document and searching for 'allocation' to get more information and code examples. The Azure documentation is somehow ambiguous and hard to find I strongly recommend you download the PDF versions and search throughout the document. 

    I hope you find this information useful. don't hesitate to ask for clarification if needed 

    If this or any other user's response answers your concern, kindly verify the answer. Thank you!

    Renesas Engineering Community Moderator

  • Thank you very much, i work on this and will get back if i have any query on this.