Upgraded app from v8.4 to v9.3 - now running out of memory

Hello,
I experienced the same problem when upgrading from 8.3 to 9.3.
In 9.x, the custom memory managment function definition has changed.
You must delete all your #define LV_MEM_CUSTOM_XXX
In lv_conf.h (near line 43), replace

#define LV_USE_STDLIB_MALLOC    LV_STDLIB_BUILTIN

by

#define LV_USE_STDLIB_MALLOC    LV_STDLIB_CUSTOM

It’ll prevent LVGL from using standard core lv_malloc/lv_realloc/lv_free functions

Then you must define your own implementation of LVGL core memory functions in a .c file which include the lvgl core header.
On the ESP32-S3 N16R8 i use, it works like a charm (I dynamically load and decode 480x480 png from SD Card).

Here is my lv_custom_mem.c. Beware of the include of the lv_mem.h header


/*********************
 *      INCLUDES
 *********************/
#include "../.pio/libdeps/esp32s3dev/lvgl/src/stdlib/lv_mem.h" // ../lv_mem.h"
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_CUSTOM
#include "esp_heap_caps.h"



/*********************
 *      DEFINES
 *********************/

/**********************
 *      TYPEDEFS
 **********************/

/**********************
 *  STATIC PROTOTYPES
 **********************/

/**********************
 *  STATIC VARIABLES
 **********************/

/**********************
 *      MACROS
 **********************/
/**********************
 *   GLOBAL FUNCTIONS
 **********************/

void lv_mem_init(void)
{
    return; /*Nothing to init*/
}

void lv_mem_deinit(void)
{
    return; /*Nothing to deinit*/

}

lv_mem_pool_t lv_mem_add_pool(void * mem, size_t bytes)
{
    /*Not supported*/
    LV_UNUSED(mem);
    LV_UNUSED(bytes);
    return NULL;
}

void lv_mem_remove_pool(lv_mem_pool_t pool)
{
    /*Not supported*/
    LV_UNUSED(pool);
    return;
}

void * lv_malloc_core(size_t size)
{
    return heap_caps_malloc(size,MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
}

void * lv_realloc_core(void * p, size_t new_size)
{
    return heap_caps_realloc(p, new_size,MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
}

void lv_free_core(void * p)
{
    heap_caps_free(p);
}

void lv_mem_monitor_core(lv_mem_monitor_t * mon_p)
{
    /*Not supported*/
    LV_UNUSED(mon_p);
    return;
}

lv_result_t lv_mem_test_core(void)
{
    /*Not supported*/
    return LV_RESULT_OK;
}

/**********************
 *   STATIC FUNCTIONS
 **********************/

#endif /*LV_STDLIB_CLIB*/

Hope it’ll help

1 Like