How to reduce the surface cache size?

285 views
asked Oct 14, 2015 in System Integration by Customer
In order to control the memory consumption, the cache for bitmap resources should be limited. How to achieve this?

1 Answer

0 votes
answered Oct 14, 2015 by EmWi Support

All bitmap resources and internal surfaces are allocated within the surface cache of the Graphics Engine. As long as there is enough space within the surface cache, all loaded bitmap resources remain within this cache, in order to avoid future reloading and decompressing of bitmaps from the flash memory.
This article describes how to limit the size of the surface cache.

By default, the cache size is 8 MByte! The surface cache size is defined by the macro EW_MAX_SURFACE_CACHE_SIZE. The value of the macro determines the desired cache size in bytes. It is declared within the file ewgfxdefs.h - please do not modify this file!
In order to change the cache size, it is sufficient to set the define within your makefile and to rebuild your project.
Alternatively, the macro can be defined in your 'ewextgfx.h' file. 
For example:

#ifndef EW_MAX_SURFACE_CACHE_SIZE
  #define EW_MAX_SURFACE_CACHE_SIZE  0x100000
#endif

In this example the cache size is set to 1 MB.
In order to reduce this cache to a minimum, you can set it to 0. In this case, all bitmap resources are removed from RAM immediately after usage.
Don't forget to recompile your project after appending the macro definition. Also please note, that the cache exists for performance reasons. The reduction of the cache size may thus affect the performance of your GUI application. In particular the slow decompression of images will be repeated more frequently if the cache is too small.

commented Nov 25, 2019 by harbottle
Does the EW framework remove unused bitmaps from the cache?

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...