Big big memory leak: the DocumentTab's are not finalized
@swilmet
Submitted by Sébastien Wilmet Link to original bug (#761181)
Description
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…