== Tracking memory errors and leaks in WebKitGTK+ == Tracking memory errors and leaks in WebKitGtk is similar to how is done for other GTK/GNOME software, with a few extra considerations. The Valgrind page at GNOME wiki contains some tips, and is a useful reading as a starting point. === WebKit1 === {{{ G_SLICE=always-malloc G_DEBUG=gc-friendly,resident-modules valgrind \ --tool=memcheck --leak-check=full --leak-resolution=high \ --num-callers=20 --log-file=vgdump --smc-check=all \ WebKitBuild/Release/Programs/GtkLauncher }}} Notice the ''--smc-check-all'' flag, which enables checks for self modifying code. This is needed because the JIT dynamically patches the generated code for some of it's optimizations. === WebKit2 === {{{ G_SLICE=always-malloc G_DEBUG=gc-friendly,resident-modules valgrind \ --tool=memcheck --leak-check=full --leak-resolution=high \ --num-callers=20 --log-file=vgdump --smc-check=all --trace-children=yes \ WebKitBuild/Release/bin/MiniBrowser }}} Here, the interesting bit is ''--trace-children=yes'', which tells valgrind to also hook into any child process spawned by the original program. For WK2 this is required if you want to check memory in the Web process (which you most likely do), otherwise it will only check it in the UI process. Notice that for both WK1 and WK2, the corresponding launcher programs are used instead of the provided script, in order to avoid checking for errors in the script's runtime, which apart from been undesired, will slow down the process even more. === List of memory leaks found in WebKit === * [GTK] Memory leaks in WebCore::FontCache::createFontPlatformData https://bugs.webkit.org/show_bug.cgi?id=115586 * ''FIXED'' ~~[GTK] Fix memory leak in WebKitBackForwardList http://trac.webkit.org/changeset/150232~~ === List of memory leaks found in external modules === * **at-spi2-atk**: * ''FIXED'' ~~Memory leaks due to not calling dbus_error_free() https://bugzilla.gnome.org/show_bug.cgi?id=698951~~ * **atk** * ''FIXED'' ~~AtkSocket not freeing 'embedded_plug_id' when destroyed https://bugzilla.gnome.org/show_bug.cgi?id=699256~~ === Related === * [wiki:WebKitGTK/Debugging Debugging in WebKitGTK+]