fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Memory problems fixed


From: Josh Green
Subject: Re: [fluid-dev] Memory problems fixed
Date: Tue, 28 Nov 2006 21:24:59 +0000

Hello Paul,

On Tue, 2006-11-28 at 19:38 +0000, Paul Millar wrote:
> Hi all,
> 
> I'm still having problems (with CVS HEAD) with memory not being freed.  This 
> seems to have been caused by still-active voices maintaining their lock on 
> the sfont's refcount (see start of delete_fluid_defsfont() in 
> src/fluid_defsfont.c).
> 

Yeah, I did see that and suspected trouble.

> The solution I've attached is to explicitly call fluid_voice_off() before 
> trying to delete the sfont(s).  This should be OK, right?  For neatness, I've 
> also updated fluid_voice.c so neither fluid_voice_off( NULL)  nor calling 
> fluid_voice_off() twice with the same voice crashes fluidsynth.
> 

Hmm, seems reasonable.  I suppose it would be better to just turn off
those voices for the given SoundFont, but seems like your solution would
work and is probably the easiest.

> I found a couple of other minor memory leaks: the string tokenizer usage in 
> fluid_settings.c and a leaked FILE pointer in fluid_defsfont.c.  Both should 
> be fixed in the patch.
> 

I already axed the string tokenizer and created a simpler function which
no longer requires an instance to be allocated.  Not checked in yet I
guess.  I did that after seeing the static allocated token instances
(potentially evil if more than one synth instance is being used).  Good
find on the leaky FILE pointer.

> With these changes, I'm now only seeing a leak of around 10kB or so.  This 
> all 
> seems to come from libasound and libc, and (from what I can see) isn't  
> fluidsynth's fault.
> 

We can hope it isn't FluidSynth's fault ;)  Its possible FluidSynth
should be calling appropriate close/free functions for those libraries,
and isn't.  I noticed a similar leak with LASH support.  All rather
small leaks though, and as long as it isn't something that keeps
growing, it should be OK.

> I've tested the code against my simple test-case and it seems to work OK.  
> But, I'm new to fluidsynth code; perhaps some more familiar with the 
> code-base should review this patch.
> 

I'll have a look at it.  I know enough to hopefully get it right the
third time round ;)

I think the main area that I really should be more familiar with is all
thread/mutex related issues with FluidSynth.  That is one area where I
could really screw things up.  A more in depth analysis needs to be
done.  I've started by beginning to document all public API functions
(in the code, where it is most useful).  Lots of work though.

> Cheers,
> 
> Paul.

Thanks again for the patch!  Cheers.
        Josh






reply via email to

[Prev in Thread] Current Thread [Next in Thread]