96 views
in GUI Development by
Hi,

In our project Embedded Wizard Version 11 is used and Target Platform is IMXRT.
We have 13 images and One image at a time to be shown based on the current language selected.
The average size of each image is around 1 MB.
When language is continuously changed, the image keeps on flipping according to the language.

During continuous loading of the image, the Embedded wizard crashed.

When memory analysis is done, Heap memory is overflowed.

We want to make sure that the existing image is removed completely before the new image is loaded. Is there any solution to make sure of this point?

During the error scenario, when loading the image, the target is throwing memory overflow as below error codes:

      -  EMWI ERROR: code: 41, EMWI ERROR: code: 113, EMWI ERROR: code: 321.

Please suggest a solution for unloading the current displaying image completely from memory manually if needed before the new image gets loaded.

The memory log details during the error scenario:

GetHeapInfo - aNoOfMemoryPools: 1,
GetHeapInfo - aTotalSize: 4194248,
GetHeapInfo - aFreeSize: 2170660,
GetHeapInfo - aNoOfUsedBlocks: 640,
GetHeapInfo - aNoOfFreeBlocks: 22,
GetHeapInfo - aSmallestFreeBlock: 16,
GetHeapInfo - aLargestFreeBlock: 1093680,
GetHeapInfo - aSmallAllocCounter: 818,
GetHeapInfo - aLargeAllocCounter: 144,
GetHeapInfo - aFreeCounter: 322,
   30632 bytes occupied by 104 Chora objects (peak 30812 bytes)
    4824 bytes occupied by 127 strings (peak 4824 bytes)
  711218 bytes occupied by Graphics Engine objects (without any framebuffers) (peak 3188812 bytes)
TOTAL : 746674 bytes, TOTAL PEAK : 3224436 bytes

1 Answer

0 votes
by

Hello,

please let me know the settings of your ewconfig.h file in order to see the current settings and to provide you any recommendations.

Furthermore, let me recommend the section Optimizing the Data Memory (RAM) usage.

Thanks and best regards,

Manfred.

by
Hello Manfred,

Please find the ewconfig file details below:

#include "ewdef.h"

#ifndef EWCONFIG_H
#define EWCONFIG_H

#define EW_PLATFORM_STRING    "IMXRT1170-EVK"

#define IRAM_BASE_ADDR        0x20240000
#define IRAM_SIZE_BYTES       ((15 * 1024 * 1024)/10)

#define SDRAM_BASE_ADDR       0x60200000        /* NONCACHEABLE_SECTION*/
#define SDRAM_SIZE_BYTES      (4 * 1024 * 1024)

#define EW_USE_TERMINAL_INPUT 0
#define EW_CPU_LOAD_MEASURING 1

#define RTC_MINIMUM_TIME      978307200      /* 2001-01-01 0:00 */
#define RTC_DEFAULT_TIME      1619535600     /* 2021-04-27 15:00 */

#define EW_USE_EXTERNAL_FLASH 1

#if EW_USE_EXTERNAL_FLASH == 1

  #define EW_BITMAP_PIXEL_SECTION_NAME ".HMI_EMBWIZ_RESOURCE"
  #define EW_FONT_PIXEL_SECTION_NAME   ".HMI_EMBWIZ_RESOURCE"
  #define EW_FONT_DATA_SECTION_NAME    ".HMI_EMBWIZ_RESOURCE"
  #define EW_CONST_STRING_SECTION_NAME ".HMI_EMBWIZ_RESOURCE"

#endif

#define EW_USE_DOUBLE_BUFFER              1

#define EW_DISPLAY_WIDTH                800
#define EW_DISPLAY_HEIGHT               480
#define EW_FRAME_BUFFER_WIDTH              800
#define EW_FRAME_BUFFER_HEIGHT             480

/* calculated addresses for framebuffer(s) */
#define EW_FRAME_BUFFER_ADDR     IRAM_BASE_ADDR
#define EW_FRAME_BUFFER_SIZE  EW_FRAME_BUFFER_WIDTH * EW_FRAME_BUFFER_HEIGHT * EW_FRAME_BUFFER_DEPTH

#if EW_USE_DOUBLE_BUFFER == 1

  #define EW_DOUBLE_BUFFER_ADDR  (EW_FRAME_BUFFER_ADDR + EW_FRAME_BUFFER_SIZE)
  #define EW_DOUBLE_BUFFER_SIZE  EW_FRAME_BUFFER_SIZE

#else

  #define EW_DOUBLE_BUFFER_ADDR  0
  #define EW_DOUBLE_BUFFER_SIZE  0
  #define EW_NUMBER_OF_FIELDS    3

#endif

#define EW_USE_GRAPHICS_ACCELERATOR     1

#define EW_TOUCH_AREA_MIN_X                    0
#define EW_TOUCH_AREA_MIN_Y                    0
#define EW_TOUCH_AREA_MAX_X                    800
#define EW_TOUCH_AREA_MAX_Y                    480
#define EW_TOUCH_SWAP_XY                       0

// #define EW_PRINT_TOUCH_DATA
// #define EW_PRINT_TOUCH_EVENTS

//#define EW_MEMORY_POOL_ADDR      (EW_FRAME_BUFFER_ADDR + EW_FRAME_BUFFER_SIZE + EW_DOUBLE_BUFFER_SIZE)
//#define EW_MEMORY_POOL_SIZE      SDRAM_SIZE_BYTES - EW_FRAME_BUFFER_SIZE - EW_DOUBLE_BUFFER_SIZE

#define EW_MEMORY_POOL_ADDR      SDRAM_BASE_ADDR //(EW_FRAME_BUFFER_ADDR + EW_FRAME_BUFFER_SIZE + EW_DOUBLE_BUFFER_SIZE)
#define EW_MEMORY_POOL_SIZE      SDRAM_SIZE_BYTES // - EW_FRAME_BUFFER_SIZE - EW_DOUBLE_BUFFER_SIZE

#define EW_EXTRA_POOL_ADDR       0
#define EW_EXTRA_POOL_SIZE       0

// #define EW_PRINT_MEMORY_USAGE                 //Enable whenever RAM metrics needs to be measured
// #define EW_DUMP_HEAP

// #define EW_SUPPORT_GFX_TASK_TRACING
// #define EW_PRINT_GFX_TASKS
// #define EW_PRINT_PERF_COUNTERS
// #define EW_USE_IMMEDIATE_GARBAGE_COLLECTION

#define EW_MAX_STRING_CACHE_SIZE      0x4000
#define EW_MAX_SURFACE_CACHE_SIZE          0  // 0x800000
#define EW_MAX_GLYPH_SURFACE_WIDTH       512
#define EW_MAX_GLYPH_SURFACE_HEIGHT      512
#define EW_MAX_ISSUE_TASKS               100  //200

#define EW_LAZY_LOAD_BITMAPS                              0
#define EW_LAZY_LOAD_BITMAPS_IF_ANIMATED_ONLY             0
#define EW_DISCARD_BITMAPS                                0
#define EW_DISCARD_BITMAPS_IF_ANIMATED_ONLY               0
#define EW_DISCARD_BITMAPS_IF_NOT_USED_IN_CURRENT_UPDATE  0
#define EW_DISCARD_BITMAPS_IF_NOT_USED_IN_RECENT_UPDATES  0
#define EW_CACHE_OFFSCREEN_SURFACES                       0

// #define EW_DONT_CHECK_INDEX

// #define EW_DONT_USE_WARP_FUNCTIONS
// #define EW_DONT_USE_PATH_FUNCTIONS
// #define EW_DONT_USE_BIDI_FUNCTIONS
// #define EW_DONT_USE_GRADIENTS
// #define EW_DONT_USE_COMPRESSION
// #define EW_DONT_USE_INDEX8_SURFACES
// #define EW_DONT_USE_RGB565_SURFACES
// #define EW_DONT_USE_NATIVE_SURFACES
// #define EW_DONT_USE_NATIVE_SURFACES_AS_DESTINATION

#endif /* EWCONFIG_H */

/* pba, mli, msy */
by

Hello,

thanks for providing the settings. I assume that the main problem is the memory fragmentation.

One question before optimizing the memory: You mentioned that the images are 1 MB large. What is the Format of the bitmap resources? In case there is no alpha channel required, you can use RGB565 instead of Native.

Furthermore, you can reduce the glyph cache size, e.g.

#define EW_MAX_GLYPH_SURFACE_WIDTH       256
#define EW_MAX_GLYPH_SURFACE_HEIGHT      256

This saves 192 KByte RAM.

Finally, you can try the options for lazy loading and discarding of bitmaps.

Does one of these hints solve the issue? Alternatively, the immediate garbage collection can be a solution.

Let me know.

Best regards,

Manfred

 

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

...