darcs patch: fixes a possible memory leak

Hi,
this fixes a possible memory leak: when "loadQueryFont" is called the
returned FontStruct must be freed after using it.
By the way, this was the problem of xmobar too.
Ciao
Andrea
Mon Jun 25 12:16:29 CEST 2007 Andrea Rossato

mailing_list:
Hi, this fixes a possible memory leak: when "loadQueryFont" is called the returned FontStruct must be freed after using it.
By the way, this was the problem of xmobar too.
Ciao Andrea
Mon Jun 25 12:16:29 CEST 2007 Andrea Rossato
* fixes a possible memory leak
should we have something like: withFont $ \f -> do some action to track this resource? Or perhaps tie it to ForeignPtr, to have the GC free it automatically? -- Don

On Mon, Jun 25, 2007 at 08:43:56PM +1000, Donald Bruce Stewart wrote:
should we have something like:
withFont $ \f -> do some action
to track this resource? Or perhaps tie it to ForeignPtr, to have the GC free it automatically?
Since we have Decoration.withGC and setFont requires the G(aphic)C(context) I think we could modify that function. Something like: withGC :: Drawable -> (Display -> Drawable -> GC -> FontStruct -> X ()) -> X () If this is ok, I'll send the patch (and you can forget this one). Andrea

mailing_list:
On Mon, Jun 25, 2007 at 08:43:56PM +1000, Donald Bruce Stewart wrote:
should we have something like:
withFont $ \f -> do some action
to track this resource? Or perhaps tie it to ForeignPtr, to have the GC free it automatically?
Since we have Decoration.withGC and setFont requires the G(aphic)C(context) I think we could modify that function. Something like:
withGC :: Drawable -> (Display -> Drawable -> GC -> FontStruct -> X ()) -> X ()
If this is ok, I'll send the patch (and you can forget this one).
Andrea
I guess its a bit complex, but if that's what needs to be done to handle the resource automatically, then it probably should be done. -- Don

On Mon, Jun 25, 2007 at 09:43:59PM +1000, Donald Bruce Stewart wrote:
I guess its a bit complex, but if that's what needs to be done to handle the resource automatically, then it probably should be done.
It is a bit more complex than I first thought. We need also Decoration.newDecoration get the font name, if the decoration is going to have some text on it, but that would automate the use of those resources. newDecoration :: Window -> Rectangle -> Int -> Pixel -> Pixel -> String -> (Display -> Window -> GC -> X ()) -> X () -> X Window I think this would be far better, since GC and FontStruct are major sources of memory leaks. I'll submit a patch, so forget about this one. Andrea
participants (2)
-
Andrea Rossato
-
dons@cse.unsw.edu.au