This is probably a long shot, but I wondered if anyone had any suggestions for overcoming a problem I'm experiencing.
A little bit of background info to explain the problem:
My soft synth is written in C++, in the form of a lib file. When the synth is used for a demo/intro, the demo will simply link to the lib in order to use it.
For the synth VST GUI, I have a C++ DLL that contains the lib file for the synth. My synth interface is written in C# and I communicate with the synth via a C++ DLL (which links to the synth lib and acts as a wrapper for the synth and exposes various method to initialize the synth, get/set params and patch names etc). The C# GUI communicates by using PInvoke to call the methods in the DLL, which in turn calls methods in the synth lib code.
My problem is that when debugging, the C# code calls a method in the DLL to initialize the synth which creates all the synth parts in memory (patches, wavetables etc etc). When debugging terminates, I'm left with a rather large memory leak as the memory allocated by the native code is not freed. After a few test runs in Visual Studio using the debugger, I'm out of memory.
I'm wondering if there is any way round this without having explicit cleanup code in the DLL to free the memory? I'm also concerned that if I do add code to free the memory, I will have no way to call it when debugging terminates and execution is suddenly halted before I get a chance to fire off a call to the cleanup code and free the memory.
Any suggestions most appreciated, many thanks,
Raizor