Memory leak with Engine.loadAudioFilesIntoPool
-
@Elezeid Are you 100% sure it's caused by that function call?
-
@Elezeid said in Memory leak with Engine.loadAudioFilesIntoPool:
Engine.loadAudioFilesIntoPool();
Are you sure you aren't calling this function anywhere else in your code?
-
I would probably first check to see if changing 'save in preset' for your combobox changes anything. Depending on how you're using your combobox that might help.
I would probably next, check on anything calling .changed(); on your combobox....
ie; if you have a rogue 'next/previous' button calling .changed(); at the wrong time.
def sounds like you have a weird loop somewhere.
@dannytaurus said in Memory leak with Engine.loadAudioFilesIntoPool:
Are you sure you aren't calling this function anywhere else in your code?
Engine.loadAudioFilesIntoPool();and this
-
@d-healey Yes. When this line is commented out, the issue is gone.
@dannytaurus Yes. I used ctrl+F to make sure.
@Chazrox there aren't any other functions like that tied to the combo box, the script is copied line for line from one of David Healey's tutorials. It's possible that it's become outdated?
I'll try unchecking "save in preset" but it's sort of an integral component of my presets, so if that does fix it, then I'll be in some trouble haha.
-
@Elezeid said in Memory leak with Engine.loadAudioFilesIntoPool:
I used ctrl+F to make sure.
That only searches the current view, did you check all scripts in your project and all callbacks? There is a Find All Occurrences tool (ctrl + shift + f) that might help. However I doubt this is the issue since you say commenting out that line solves it.
-
@d-healey Thanks David, unfortunately this is indeed the only occurrence.
Am I really the first to run into this issue? If so, that definitely suggests user error of some kind, but I really don't know where I might have gone wrong!
-
@Elezeid said in Memory leak with Engine.loadAudioFilesIntoPool:
Am I really the first to run into this issue?
First one to report it at least, I haven't tested for it though.
-
I made a minimal project to test the issue and it is indeed present.
Here is the entire onInit:
Content.makeFrontInterface(600, 600); const var ConvolutionReverb1 = Synth.getAudioSampleProcessor("Convolution Reverb1"); const irs = Engine.loadAudioFilesIntoPool(); //cmbIR const cmbIR = Content.getComponent("cmbIR"); inline function oncmbIRControl(component, value) { if (value > 0) ConvolutionReverb1.setFile(irs[value - 1]); }; Content.getComponent("cmbIR").setControlCallback(oncmbIRControl); cmbIR.set("items", ""); for (x in irs) cmbIR.addItem(x.replace("{PROJECT_FOLDER}").replace(".wav"));
I've tested this in multiple DAWs as well as on Mac and PC and the memory leak remains. I tried disabling 'saveInPreset' but that didn't help either. The issue is especially egregious when changing presets as well. If you just cycle through presets you can see the RAM load growing with each click.
David suggested putting a check in the combo box's callback to see if the selected IR is already loaded, and if it is don't load it again. I think this is a great idea, but I don't quite know how to go about that.
-
@Elezeid If you replace the contents of your control callback with this code it will check if that IR is already loaded before attempting to load the IR.
if (!value) return; local currentFile = ConvolutionReverb1.getFilename(); local newFile = irs[value - 1]; if (currentFile == newFile) return; ConvolutionReverb1.setFile(newFile);
-
@d-healey Thanks David,
I tried this and unfortunately the behavior is the same. Out of curiosity, I checked the total file size of my collection of Impulse responses, and wouldn't you know it? That's almost exactly how much the RAM increases by every time a preset is selected!
It looks to me like
Engine.loadAudioFilesIntoPool();
Is running every time a preset is selected, (regardless of whether saveInPreset is active in the project).
What would be really great is if there was such a function as
Engine.purgeAudioFilesFromPool();
Or something to that effect. If there was, I could simply put it at the top of the hierarchy so that onInit any lingering audio files are kicked out in advance before loadAudioFilesIntoPool runs.
-
Can you send me your project?
-
@d-healey Sure thing. Here it is without the IRs. Feel free to throw any old audio files in there.
-
Well I didn't find a solution but I have confirmed the issue. You can demonstrate it with a standalone build, no need to have a DAW in the equation.
@Christoph-Hart You should probably take a look at this. Here's the project as above but I added some IRs.