Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 1

Help Needed to fix Gtk/Widget.cs

Hello community!

We use Gtk# in our project for ATM (Air Traffic Management) software.

Our customer reported a memory leak when using our application.

After several months of investigation, we finally found out that the method SizeRequest of Gtk.Widget class was leaking. We found a fix for that leak on 2.12.45 branch. A patch on gtk.dll was proven to solve our memory leak because we launched endurance tests and nmon monitoring proved that memory consumption was dramaticaly reduced because of that fix. We launched Resharper Ultimate tools to investigate unmanaged memory and it showed that the solution fixed precisely the method SizeRequest memory leak.

 

Here is the solution we have found. The idea is to use Requisition property with the object instead of instantiating a new one every time the method is called:

public Gtk.Requisition SizeRequest() {
Gtk.Requisition requisition = Requisition;
Gtk.Application.AssertMainThread();
gtk_widget_size_request(Handle, ref requisition);
return requisition;
}