-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GTK Platform/GtkSharp has a slow memory leak with Drawable controls #1796
Comments
for context, here are my 2017 notes from the fixes to the original: I have a GTK3 Eto.Application form with a bunch of custom (i.e. Drawable) based controls (text and bar gauges) and for the last several weeks have been chasing down a Running Valgrind on it shows the following smoking gun after running the app for about 5 minutes (with all the controls): ==3212== 1,389,427 (387,200 direct, 1,002,227 indirect) bytes in 4,400 blocks are definitely lost in loss record 51,757 of 51,757 This call gets made in HandleDrawn here:
So the CreatePangoContext (in the GTK# library) looks like so:
and the GraphicsHandler class saves the passed pango context but it looks like the Dispose on the Graphics object at the end of the using block is I realize this may in fact be a GTK# issue and I'm still trying to make sense of GTK#'s Pango.Context and GLib.Object code so I understand how/why the dispose |
I have modified the example app by adding the full Eto and GtkSharp libraries so it can be debugged/presented. See here (and search for "get-pango-context") for details on the 2 variants: I am testing this now on Windows 10, Ubuntu 20.04, and my embedded system an all show significant reduction in the leaking rate which is now almost flat -I will continue testing the code and may run it with valgrind again so see what remaining items are still leaking. |
Also - for future testing purposes I have a proposed update to the DrawLoop Eto test that exercises the pango aspect of Drawable more strenuously - I can make a pull request for that once we are done getting the leak issue nailed down. |
test results: |
even better news, discovered that get get-pango-context api call is being mapped to a property i.e. h.Control.PangoContext not a method - and already exists in GtkSharp so the fix is only on the Eto side. I will re-run testing and then submit a PR for this shortly.. |
Thanks again for looking into this issue! I think there was a reason why I didn't use the PangoContext property at one point, but I can't remember exactly why. If it works then 🤷🏻♂️ |
I have an application that uses many Drawable controls to put up custom gauges for my application.
Updating these controls will slowly consume memory/resources on the Gtk platform running on GTK+3
on both Unix and Windows. The memory issue does not occur on the WPF build and I have no mac to test there.
To isolate the problem, I have created the following test app that demonstrates the issue and put up on GitHub:
https://github.com/derbyw/EtoGtkReseourceLeakTest.git
see the readme for info on what buttons do. there are options to stop/start the updates
The app puts up a bunch of controls (16 text 4 bar gauge) and feeds them at about 100ms - the app will display a running total of memory which will slowly climb as the app runs. If you let it run in VS 2019 you can also watch it rise over time - give it a good 10 minutes to see the distinct ramp.
The app is currently running against the current release (2.5.6) built in VS 2019. running against the msys2 Gtk+3 system on Windows and also shows against the Gtk+-3.22.26 on Linux (embedded) and also Ubuntu LTS 18.04. (can't recall the GTS version there).
I had run into this previously on my original build for the embedded system and ended up fixing some of the auto generated code in GtkSharp after a bunch of time spent with Valgrind, etc. That system also supported the Gestures changes I proposed a while back and were not tied up cleanly to get back to Harry for GtkSharp. So I've been stuck at Eto.Forms from about 2 year ago till I had enough time to fix things again and get sync'd with the project. I finally got the time, ported everything to .Net Core 3.1, crossing my fingers that the issue was fixed in the meantime -- alas the issue remains.
IIRC - the leak was be related to the various resources allocated and release when the drawable control get drawn i.e. each point event. The reference counting seemed to get messed up and "freed" Pango, etc. resources don't quite all get returned. I will try to find my changes from when I fixed this last time to see what I modified. I was able to finally get the process net memory neutral and have been running that way for the last 2 years. Unfortunately, I have not been able to get the new GtkSharp build to build on my embedded machine so I will continue work there.
The text was updated successfully, but these errors were encountered: