views:

52

answers:

1

Hi folks, here is a simple question. Can you help me find the memory leak in this Vala code ? If it helps I can post the generated c code too ^^

using GLib;
using Gtk;
using Gee;

void test1 () 
{
    Gee.ArrayList<Gdk.Pixbuf> list = new Gee.ArrayList<Gdk.Pixbuf>();

    for( int a = 0; a < 10000; a++)
    {
        string path = "/usr/share/icons/gnome/48x48/stock/data/stock_lock.png";

        list.add( new Gdk.Pixbuf.from_file( path ) );
    }

    list.clear(); 

    // when the function returns it *should* free all alocated memory, or am I missing something?            
}

int main (string[] args) 
{
    Gtk.init( ref args);

    // the memory usage here is ~3mb
    test1();
    // here it is ~94mb

    Gtk.main();
    return 0;
}