Can rom/miniz be used on a reference ESP32 (520KB ram), which offers just under 300KB of usable heap in user space? When running the following snippet as a test on esp-idf v3.2.2:
Code: Untitled.c Select all
#include <stdio.h>
#include <rom/miniz.h>
#include <lwip/opt.h>
void app_main() {
printf("Free heap memory: %d\n", esp_get_free_heap_size());
printf(" 8-BIT blocks available: %d\n", heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
printf(" 32-BIT blocks available: %d\n", heap_caps_get_largest_free_block(MALLOC_CAP_32BIT));
printf("Memory needed for a tdelf compressor: %d\n", (int) sizeof(tdefl_compressor));
tdefl_compressor* comp = (tdefl_compressor*)malloc(sizeof(tdefl_compressor));
if (comp == NULL) {
printf("Failed to allocate compressor!!!!!\n");
} else {
printf("Free heap memory: %d", esp_get_free_heap_size());
printf("Compressor allocated.\n");
}
}
Code: Untitled.bsh Select all
Free heap memory: 296484
8-BIT blocks available: 126412
32-BIT blocks available: 126412
Memory needed for a tdelf compressor: 167744
Failed to allocate compressor!!!!!
It looks as thought about 167KB of contiguous memory is needed to allocate tdefl_compressor, which fails. Many others have successfully used miniz on ESP32, what am I missing please?
Thanks!
