GNOME Bugzilla – Bug 761181
Big big memory leak: the DocumentTab's are not finalized
Last modified: 2018-02-23 16:25:12 UTC
A DocumentTab contains the DocumentView (subclass of GtkSourceView) which contains a Document (subclass of GtkSourceBuffer). With a tool like gobject-list: https://blogs.gnome.org/danni/2011/02/17/ld_preload-gobject-lifetime-debugging-tool/ https://git.collabora.com/cgit/user/danni/gobject-list.git/ We can see that the Document, DocumentView and DocumentTab objects are not finalized!! This is a huge memory leak. A beginner writing Vala code (i.e. me several years ago) will not pay enough attention to memory handling, reference counting, avoid reference cycles and so on. In Vala, *most* of the time you don't need to pay attention to memory handling. The problem is in "most of the time"; not always… So here you have the result… the opened documents are never freed. Also, it would be better to call gtk_widget_destroy() on a tab that we no longer need. In normal code this would break reference cycles. Except that Vala never g_object_unref() other objects in dispose(). Vala does that in finalize. Thanks Vala…
In document.vala, there is this instance variable: > public DocumentTab tab; It should be a weak ref. Will test later.
I've made some progress to fix this bug: commit 1daf96cb17bdd83e0cd83231097f17bedf46c367 commit cf118d05741565b1f543bf6430a1aa6ce53683d1 commit cba23f861067a1769605865f4d6e482806b7b8aa
Still not found where the reference is leaked. A possible short-term solution is to empty the GtkTextBuffer when closing a tab.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-latex/issues/35.