Ticket #1167 (new task)

Opened 8 years ago

Last modified 7 years ago

Think about resource management

Reported by: guest Owned by: axel
Priority: normal Milestone: 1.0
Component: general (Gtk+, Glib) Version: 0.10.2
Keywords: Cc:


It is very easy to get a memory leak. For example these buttons will never get freed:

    replicateM_ 1234 $ do
        b <- buttonNew
        onStateChanged b $ \_ -> widgetGetSize b >>= print

You can correct this example with eventGetWindow, but that doesn't apply to signals.

The memory leaks in a typical app are small. However, avoiding these leaks may involve API changes so it's important to think about. I suggest, at least, an explicit "objectUnref" action that cancels the finalizer. Then app writers can take care of memory management.

As a nicer API, since a UI is just a tree, perhaps Containers could automatically manage the refs for their children.

Change History

Changed 7 years ago by axel

  • owner changed from somebody to axel

There is the function widgetDestroy in Widget but there should be an equivalent function in Object.

Note: See TracTickets for help on using tickets.