Out of memory but cannot increase LV_MEM_SIZE

Working on a project with a dozen screens (tabs), after some sequences of buttons and related actions it hangs and i get this error:
[Error] (585.288, +585288) lv_draw_sw_box_shadow: Asserted at expression: sh_buf != NULL (Out of memory) lv_draw_sw_box_shadow.c:125

I tried a number of solutions, the error is the same, allways this box shadow thing
Where it happens is allways the same button and related action, but these do not allways result in an error. It depends on what actions i did before it.
Its complex, 11000 lines of code, virtual tasks, interrupts, sd card etc…
Some statistics:

LVGL Object Creation Counts (sorted by quantity):

lv_label_create: 85
lv_btn_create: 46
lv_checkbox_create: 25
lv_slider_create: 23
lv_button_create: 8
lv_roller_create: 4
lv_spinbox_create: 4
lv_led_create: 3
lv_bar_create: 2
lv_tft_espi_create: 1
lv_indev_create: 1
lv_tabview_create: 1
lv_obj_create: 1
lv_textarea_create: 1
lv_keyboard_create: 1
lv_msgbox_create: 1
lv_line_create: 1

I do log memory usage:

=== Memory Info ===
Heap: 4119036 / 4401952 bytes free
PSRAM: 3998496 / 4194304 bytes free
Stack: 4560 bytes free

Total DRAM: 261692 bytes
Free DRAM: 173732 bytes
Largest Free Block in DRAM: 110580 bytes
mon.total_size: 84376
mon.free_cnt: 32
mon.free_size: 7612
mon.free_biggest_size: 4808
mon.used_cnt: 2057
mon.max_used: 79400
mon.used_pct: 91
mon.frag_pct: 37

The LV_MEM_SIZE is set to 92, thats the maximum otherwise i get an error that something would not fit in dram0 segment.

I already moved as much as possible to psram, i analysed the map file to make sure it moved.
The draw buffer is already in psram.
draw_buf_1 = heap_caps_malloc(DRAW_BUF_SIZE, MALLOC_CAP_SPIRAM);
disp = lv_tft_espi_create(TFT_HOR_RES, TFT_VER_RES, draw_buf_1, DRAW_BUF_SIZE);

There does not seem to be an option to allocate lgvl memory to psram…
Why does the box shadow routine needs lots of memory?

some more logging:

[Error] (67.534, +67534) lv_malloc: failed allocate memory (1682 bytes) lv_mem.c:75
[Error] (67.534, +0) lv_malloc: used: 79356 ( 95 %), frag: 65 %, biggest free: 1684 lv_mem.c:78
[Error] (67.534, +0) lv_draw_sw_box_shadow: Asserted at expression: sh_buf != NULL (Out of memory) lv_draw_sw_box_shadow.c:125

What MCU/Processor/Board and compiler are you using?

esp32 wrover with psram

What LVGL version are you using?

9.3.0 dev

To allocate to SPIRAM you can try this:

#define LV_MEM_POOL_INCLUDE     "esp_heap_caps.h"
#define LV_MEM_POOL_ALLOC(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM)

Not sure if it works, copied from ESP32S3 PSRAM usage

Another possible solution would be (never tried) to enable in sdkconfig CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY and then set LV_ATTRIBUTE_LARGE_RAM_ARRAY to EXT_RAM_BSS_ATTR, although this one is not available in sdkconfig and not sure how to add it to the project, this should allocate the LVGL internal buffer memory to SPIRAM, check Allow .bss Segment to Be Placed in External Memory

I tried a few options but the memory handling by lvgl is rather complex, i don’t want to mess too deep into the base structure.
I gave up with the esp32 wrover module, i need to redesign my PCB anyway so i switched to the esp32s3 n16r8, it has a better way of segmenting resulting in larger space for variables and now i can increase the LV_MEM_SIZE by a lot while going from 93% usage to 62% with all features back in.