I’m not positive how important this is or if the OS is smart enough to simply through a map out of RAM if it’s not being used, but I don’t see a way through the current API to the delete the map a MemoryMappedAudioFormatReader
I imagine if this was super important it would have been address because from what I’ve read these are being used in some serious production apps, but wouldn’t it make sense to be able to delete the map if you’re not currently using it?
What happens if you create your
MMAFR on the heap (
std::unique_ptr<MMAFR>()) and then just call
mmafr.reset(); when you don’t need it anymore? Does that MMAFR release everything when it goes out of scope?
Well the thing is I don’t want to actually delete the reader. The idea is basically, when the sample is being used, have the memory mapped, but when it’s not being used, release the map.
The map and the sample are kinda separate, just because I’m not currently using the map, doesn’t mean I don’t want to use it again in the future, so deleting the memory mapped file entirely isn’t the solution because I lose the ability to create the map again in the future.
I don’t follow this… You can just recreate it the same way you did the first time. Turn it into a function you can call on demand.