-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One more memory leak in the Vorbis Decoder #623
Comments
Thank you for your detailed explanations, which enable me to follow your thoughts. If you have any further suggestions or improvements, please feel free to let me know. best regards |
@schreibfaul1 thank you for the fixes. I have two comments:
|
@schreibfaul1 @ma261065 now i test ogg station long time and seems somethink still eat SPIRAM after 20min i see -200kB logline is from every 100sec |
and after hour SPIRAM 0 next minutes Core 0 register dump: Backtrace: 0x42105566:0x3fccd250 0x4205de35:0x3fccd270 0x4205e529:0x3fccd290 0x420480f9:0x3fccd2c0 0x420483ff:0x3fccd300 0x4204c738:0x3fccd320 0x4204d5f7:0x3fccd350 0x420043b8:0x3fccd370 #0 0x42105566:0x3fccd250 in mdct_shift_right(int, int*, int*) at .pio/libdeps/esp32s3mykorvo/ESP32-audioI2S-master/src/vorbis_decoder/vorbis_decoder.cpp:1745 (discriminator 3) |
I wonder if the memory leak is in audio.cpp rather than the vorbis decoder? I am using this decoder in a project where it is called from MicroPython, and it runs for days without showing a memory leak. Prior to the latest fixes there were definitely memory leaks, but not any more. Obviously by using this decoder in such a way I am not using audio.cpp, which is what makes me think the memory leak might be there... |
Primary crashlog is result point of memory out no point of leak. |
Hello mmar22, |
My tip leak is in tag info receive. When no info about track memory seems stay ok. 1277940 loop bezi rssi a memdma -72 110580 seems two info no one, but maybe other |
In the stream, a new codebook, residues, floors etc. is created for each song. This means that ~4KB are lost for each song. I corrected that, the old decoder configurations will be deleted beforehand. |
Now seems streaming ogg works fine. I see you after vorbis cpp change create many changes in audio code etc. But this changes make hard handle my spdif changes ... |
I think this is the last one.
I have printed out all the memory allocations and frees, and after your recent modifications, these are the last ones left where there is an allocation without a matching free.
In
VORBISDecoder_FreeBuffers()
there is a call tovorbis_dsp_destroy()
, which is supposed to loop through thev->work
andv->mdctright
instances, based on how many channels there are, and free them.However, in
VorbisDecode()
, there is this line:if(s_f_oggLastPage && !s_vorbisSegmentTableSize) {VORBISsetDefaults();}
which gets called before
VORBISDecoder_FreeBuffers()
Unfortunately
VORBISsetDefaults()
setss_vorbisChannels
to zero, which means whenvorbis_dsp_destroy()
gets called the two loops in there do zero iterations and thev->work
andv->mdctright
instances don't get freed.Two other things:
This line (and others like it)
if(v){free(v); v = NULL;
doesn't do what I think you are expecting, as v is passed in by value, so setting it to NULL in the function doesn't alter it outside of the functions. I don't know if that breaks anything, but it might be good to fix.You missed one of the "double if's" in
VORBISDecoder_FreeBuffers()
in your last fix - the one fors_mode_param
is still there. No big deal, but would make for neater code if it wasn't there.Thank you so much for this amazing decoder. It works extremely well for me, and with these final tweaks I think it will be even better.
The text was updated successfully, but these errors were encountered: