0

I'm using Mono + GTK# + Cairo + Pango on Ubuntu 12.04 and I found some memory leaks when using a Pango.Layout object.

I'm drawing some animation with a framerate of about 30 fps and my memory only increases. I remove a lot of code and here is what remains:

void OnDraw(DrawingArea area)
{
    Cairo.Context context = Gdk.CairoHelper.Create(area.GdkWindow);

    using (var lay = Pango.CairoHelper.CreateLayout(context))
    {
        // Nothing.  
    }

    ((IDisposable) context.Target).Dispose();
    ((IDisposable) context).Dispose();
}

Without the Pango.CairoHelper.CreateLayout call the memory remains stable, but with it increases for about 10k per second which is clearly unacceptable.

Is there something I'm doing wrong? Is Mono + GTK# + Cairo + Pango ready for production?

Mono version : 2.10.8.1-1ubuntu2.2
GTK# version : 2.12.10-2ubuntu4
Pango version : 1.30.0-0ubuntu3.1
uname : Linux ######-VirtualBox 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27 17:25:43 UTC 2012 i686 i686 i386 GNU/Linux
gburri
  • 154
  • 1
  • 2
  • 9

1 Answers1

0

AFAIK, there have been some fixes in Gtk# bindings that have not been released yet.

For example this memory leak fix.

So if I were you, I would try first with the gtk-sharp upstream version of the 2.12 branch. If that doesn't work, maybe you can spot the memory leak yourself and propose a fix? Thanks.

knocte
  • 16,941
  • 11
  • 79
  • 125
  • I found a workaround by calling `Pango.CairoHelper.CreateLayout` only once and then calling `Pango.CairoHelper.UpdateLayout` each time I want to draw my scene. – gburri Sep 12 '12 at 06:40