[webkit-dev] freeing static variables

Zoltan Herczeg zherczeg at inf.u-szeged.hu
Wed Jul 29 23:55:18 PDT 2009


any thoughts on this? I hope my qestion was clear :) I would like to pack
the static declarations into wrapper classes, so we can add platform
and/or compilation mode (debug/release) dependent functionality to all
static variables (i.e: freeing them on exit).


> Hi all,
> Valgrind reports a lot of memory leaks when QtLauncher quits, because many
> static local variables are not freed. I did a little research and realized
> there is no consistent way to define static variables in webkit:
> WebCore/css/CSSSelector.cpp: CSSSelector::extractPseudoType()
>    using a DEFINE_STATIC_LOCAL() macro
> WebCore/bindings/js/JSDOMWindowBase.cpp:
> JSDOMWindowBase::commonJSGlobalData()
>    static JSGlobalData* globalData;
> WebCore/platform/qt/CursorQt.cpp:
>    Cursors* Cursors::s_self = 0; (no static keyword)
> I belive it would be a good thing to define a template for static
> variables, which can (optionally) free static variables (enabled in debug
> mode, but sometimes it would be good to enable it in release mode as well)
> And I am wondering whether it would be worth to free (some) static
> variables if they are used in a given time period. This may help to reduce
> the memory consumption in the long run. This would be an optional feature,
> an extra flag (or timeout value) for the template, which can be enabled or
> disabled at compile time. If disabled, the value of this flag is not used
> at all.
> Regards
> Zoltan

More information about the webkit-dev mailing list