otem / Eurorack

A place for my eurorack stuff.
76 stars 9 forks source link

Sample memory will gradually fill up if you keep loading different sample sets #3

Open h4yn0nnym0u5e opened 1 year ago

h4yn0nnym0u5e commented 1 year ago

See line: https://github.com/otem/Eurorack/blob/1855b2d3cbb932842a832d948c6be230be6e3407/Samps%202/samps2/files.ino#L46

Suggest you re-implement using extmem_malloc() and extmem_free(). As I don't have the relevant hardware this is hard for me to fix and do a PR, it would be untested.

h4yn0nnym0u5e commented 1 year ago

Above is wrong, I read the code incorrectly and because you instantiate a new flashloader on each sample set load, the sample memory doesn’t leak. However, the heap memory does leak very slowly, because a new audiosample struct is allocated on every load. So when doing a load, you need something like if (samps[i] != nullptr) delete samps[i];