RAM optimization or Free up memory that are irrelevant to other event handlers


I am using S5D9 with 640KB RAM with multiple event handlers and using TFT LCD 3.5" display and i ran out of RAM memory

i use E2studio 7.8.1 with SSP 1.7.0 and GUIX 5.6.1

How can i efficiently modify the code that will lead to RAM optimization? i even tried upgrading the software version so that there won't be any need to do use canvas buffer for 90 degree orientation still, there was no reduction in RAM size.

Or is there a way i can free up the size of other/unused event handler's memory while switch from one to other? in a way RAM size can reduced?

Also, is it possible to use an external serial RAM for the excess RAM requirement? If so, how do we configure the same?

Thank You.

  • Hello, dear Ivok. Thank you for posting to the Renesas community. 

    Probably the most memory-consuming part of your code is the LCD canvas memory. before anything, I recommend you update the SSP package to the latest version (V2.5 at this time)

    It's not possible to comment on your issue without observing the code, but here's some general advice that might be useful for you. 

    -Try not to create several threads: each thread in your RTOS will have its overhead, and stack memory, check if you've assigned the proper amount of stack size in 'Thread_create.c' files. 

    -Check the memory pools in your Azure RTOS scheme: examine your code for memory pools and ensure there's no redundant or large memory pool created. check this link for more information about memory pools.

    -Try to obey the object pattern: dynamically assign memory to the new instances of your structs by utilizing malloc() function or memory pools and deallocate the unused ones when the process is done. 

    -Try not to declare object instances or structs globally as they occupy memory throughout runtime.

    After all, if your memory demands are higher than expected you can go for external SDRAM. but SDRAM isn't as fast as internal SRAM. 

    S5D9 supports extended memory address area and has an SDRAM controller, then you can simply utilize the external RAM by pointing to its address. check out the Hardware user's manual for more information. 

    I hope you find this information useful. about your code optimization, feel free to send the desired code sections. so we can investigate it for more efficient memory management.  

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

    Renesas Engineering Community Moderator

  • Thank you for sharing this information i will look onto the points separately and will get back here after that.