Page 1 of 1

[r3863] Fluidsynth: Soundfont memory leak

Posted: Sat Sep 08, 2012 4:18 am
by edward850
When using Fluidsynth, soundfonts seem to get loaded each time the music changes, but the old one is still held in memory. This fills the available memory within as much as 4 song changes with a 200MB soundfont.
Also, the error when Fluidsynth fails to load a soundfont when there isn't enough memory available is a somewhat misleading "Failed to load any MIDI patches" message.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Sat Sep 08, 2012 4:35 am
by Gez
I've encountered the same issue. Music stops playing and will only resume if the [wiki]MIDI device[/wiki] is changed to a non-Fluidsynth one or if quitting and restarting ZDoom.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Sun Oct 21, 2012 3:34 pm
by Lars2500
This is really nasty. Any chance of seeing this fixed in the near future? I too ran into this bug though I did not relate it to the Fluidsynth code but rather to the sound font used, and that will probably happen to others, too.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Sat Oct 27, 2012 11:57 am
by SyntherAugustus
Have you tried using BASSMIDI driver?

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Mon Oct 29, 2012 4:47 pm
by Lars2500
I did some further testing and found that the memory leak seems to be present in Randy's compiled fluidsynth.dll, not the ZDoom code.

There is a compiled fluidsynth dll out on the net that works flawlessly with ZDoom, does not have the memory leak and is based on the latest FluidSynth version 1.1.6. I found it in a program called jOrgan.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Tue Oct 30, 2012 11:51 am
by Enjay
Do you know why it needs libglib-2.0-0.dll and libgthread-2.0-0.dll as well when Randy's one only needs fluidsynth.dll (which is also smaller than the one from the jOrgan program)?

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Tue Oct 30, 2012 1:27 pm
by Lars2500
Enjay wrote:Do you know why it needs libglib-2.0-0.dll and libgthread-2.0-0.dll as well when Randy's one only needs fluidsynth.dll (which is also smaller than the one from the jOrgan program)?
Probably because it's simply compiled differently? :wink:

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Tue Oct 30, 2012 3:23 pm
by Gez
Randy managed to get them to link statically I suppose. If he wants to share his secrets on the topic, I know several people who would be interested.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Tue Oct 30, 2012 5:05 pm
by Graf Zahl
I guess that's an efficient compiler (MSVC) versus an inefficient one (gcc).
I have seen it quite often that GCC produces significantly larger binaries, especially when using C++ exceptions. The exception code in there is a lot more complex because it completely sidesteps Windows's exception mechanisms and rolls out its own implementation that also needs to include everything that's normally done by the system itself.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Tue Oct 30, 2012 8:58 pm
by randi
My "secrets" are that I had to muck about in config file and Makefiles and track down dependencies. It was a pain in the butt. Not so much building Fluidsynth as building glib.

Also, using a libintl replacement that uses the built-in Windows functions instead GNU's libintl saved a lot of space.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Tue Oct 30, 2012 9:56 pm
by randi
Here, I made a new build. This time with fluidsynth 1.1.6 instead of 1.1.1. Watching memory usage in task manager, it seems fine. Would anyone care to confirm?

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Tue Oct 30, 2012 11:58 pm
by edward850
That seems to fix it. Several map swaps and memory usage barely changed.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Wed Oct 31, 2012 3:28 am
by Lars2500
Fantastic! :o Yes, the memory leak is fixed. I removed the link to the alternate dll from my post as it's no longer needed.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Wed Oct 31, 2012 11:36 am
by Enjay
I've mirrored the file on the DRD ZDoom SVN build dowload page. Thank you.

Re: [r3863] Fluidsynth: Soundfont memory leak

Posted: Thu Nov 01, 2012 2:52 am
by Gez
This file should be updated too, since it is linked from the download page.