ESP32-PsRamFS
ESP32-PsRamFS copied to clipboard
Memory leak somewhere
There seems to be a memory leak.
Where? Library or in PSRamFS_Test.ino?
I did not audit PSRamFS_Test completely. I did change all the ESP_LOGx(...) to Serial.printf and fixed the formatting. I changed it to run in loop() instead of setup() with a halt at the end. I kept setup code in setup. Not much of that.
I tried a Arduino Nano ESP32 (16M flash, 8M PSRAM) and a Espressif ESP32-S3 De Kit N8R8 (8M flash, 8M PSRAM)
The leak is in both.
The biggest annoyance is that the leak is different for each iteration.
It could be as simple as an unpaired create/close. Like I said, didn't do a complete audit of PSRamFS_Test.ino and didn't create a sketch from scratch with more limited use of the library.
The leak is from 0 to 440 byes. Varies each run, each pass through loop.
23:13:16.615 -> Free PSRAM: 8385672 23:13:16.615 -> Running test setup_tesrdown 23:13:16.615 -> running test format_mounted partition 23:13:16.658 -> Free PSRAM: 8385672 ... 23:13:19.077 -> Test complete 23:13:19.077 -> Starting_Free_PSRAM (8385672) != ESP.getFreePsram() (8385456) ... 23:14:21.563 -> Test complete 23:14:21.563 -> Starting_Free_PSRAM (8385672) != ESP.getFreePsram() (8385244) ... 23:15:24.009 -> Test complete 23:15:24.009 -> Starting_Free_PSRAM (8385672) != ESP.getFreePsram() (8385032) ... 23:16:26.494 -> Test complete 23:16:26.494 -> Starting_Free_PSRAM (8385672) != ESP.getFreePsram() (8384820) ... 23:17:28.963 -> Test complete 23:17:28.963 -> Starting_Free_PSRAM (8385672) != ESP.getFreePsram() (8384588)
hi,
thanks for your feedback :+1:
folder related functions are probably leaky, does it improve if you limit the tests to read/write/append/rename/delete ?
I don't know. Not tested that way.
I would have to write sketches to specifically test each realm of functions. File, directory, etc... to find the leak.
Or exclude the directory functions from example and see if it goes away.
It will be a couple days to do that.
yes I meant to just exclude the directory functions from the example
have you tried commenting out this part?
#define UNIT_TESTS
Found it:
Application level error in PSRamFS_test.ino at line 441: if( ! PSRamFS.setPartitionSize( ESP.getFreePsram()/2 ) ) { // try to allocate half of psram
Change to: if( ! PSRamFS.setPartitionSize( ESP.getMaxAllocHeap()/2 ) ) { // try to allocate half of psram
No leaks
I'm stress testing it thoroughly ;)