[webkit-gtk] webkit-gtk - memory leak?

Toni Koski toni.koski at firsttechnology.fi
Mon Nov 1 02:20:19 PDT 2010


Hi list,

My goal is to create webkit/gtk based browser, which can be controlled 
via Linux pipe (fifo).

I have made several test with webkit, but there is always "huge" memory 
leaks.
I have used lastest webkit build: "WebKit r70732 was built on 28 October 
2010".
I assume that the leak is in the cache(maybe I am wrong).  Amount of the 
memory leak is related to loaded page.
So, everything to disabling cache has done. I have also set: "m_disabled 
= true " in the :"WebCore/loader/Cache.cpp"

I have tested both cache modes with out any effects for the memory leak:
- WEBKIT_CACHE_MODEL_WEB_BROWSER
- WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER

And same result with all methods:
- webkit_web_view_reload_bypass_cache
- webkit_web_view_load_uri
- webkit_web_view_reload





Even if I run callback function once with "gtk_widget_destroy(wk);", it 
does not release used memory.


Plese help me, I am desperate ;-)





Here is my testcode:

#include <gtk/gtk.h>
#include <webkit/webkit.h>
#include <stdlib.h>
#include <time.h>



static WebKitWebView* web_view;

static char *urls[] = {"http://www.utu.fi",
                     "http://www.ts.fi",
                     "http://www.hs.fi",
                     "http://www.google.fi",
                     "http://www.hs.fi",
                     "http://www.turku.fi"};

gboolean callback (gpointer wk)
{
       g_print("loading\n");
       //webkit_web_view_load_uri(wk, urls[rand() % 6]);
       //webkit_web_view_load_uri(wk, "http://www.hs.fi");
       webkit_web_view_reload_bypass_cache(wk);
       return TRUE;
}


int main( int argc, char *argv[])
{
     GtkWidget *window;
     GtkWidget *vbox;

     gtk_init(&argc, &argv);

     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_default_size(GTK_WINDOW(window), 1024, 768);



     web_view = WEBKIT_WEB_VIEW(webkit_web_view_new ());
     gtk_widget_set_size_request(GTK_WIDGET(web_view), 1024,768);

     //webkit_set_cache_model(WEBKIT_CACHE_MODEL_WEB_BROWSER);
     webkit_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);

     WebKitWebSettings *settings = webkit_web_settings_new();
     g_object_set(G_OBJECT(settings), 
"enable-offline-web-application-cache", FALSE, NULL);
     g_object_set(G_OBJECT(settings), "enable-private-browsing", TRUE, 
NULL);
     g_object_set(G_OBJECT(settings), "enable-scripts", FALSE, NULL);
     g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL);
     webkit_web_view_set_settings(web_view, settings);

     WebKitWebBackForwardList *back_forward_list = 
webkit_web_view_get_back_forward_list(web_view);
     webkit_web_back_forward_list_set_limit(back_forward_list, 1);

     gtk_container_add(GTK_CONTAINER (window), GTK_WIDGET(web_view));
     webkit_web_view_load_uri(web_view, "http://www.hs.fi");

     gtk_widget_show_all(window);

     g_timeout_add(12000, callback, web_view);
     gtk_main();

     return 0;
}






/toni




More information about the webkit-gtk mailing list