Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Standard run:
- //
- // $ G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=summary ./test
- //
- // ==602== LEAK SUMMARY:
- // ==602== definitely lost: 3,000 bytes in 8 blocks
- // ==602== indirectly lost: 6,608 bytes in 208 blocks
- //
- // Comment out two lines below:
- //
- // $ G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=summary ./test
- //
- // ==793== LEAK SUMMARY:
- // ==793== definitely lost: 184 bytes in 2 blocks
- // ==793== indirectly lost: 240 bytes in 10 blocks
- public static int main(string[] args) {
- var app = new Application();
- return app.run(args);
- }
- class Application : Gtk.Application {
- Gtk.Window window;
- construct {
- application_id = "com.test";
- activate.connect(on_activate);
- }
- void on_activate() {
- if (window != null) {
- window.present();
- return;
- }
- window = new Gtk.Window();
- window.resize(300, 100);
- var toolbar = new Gtk.Toolbar();
- // COMMENT TWO LINES TO SEE MEMLEAKS DISAPPEAR
- Gtk.ToolButton tb = new Gtk.ToolButton.from_stock("gtk-info");
- toolbar.insert(tb, 0);
- var vbox = new Gtk.VBox(false, 0);
- vbox.pack_start(toolbar, false);
- window.add(vbox);
- window.show_all();
- add_window(window);
- }
- }
Add Comment
Please, Sign In to add comment