[webkit-dev] WebKit memory management?
ap at webkit.org
Wed Jun 4 01:20:05 PDT 2008
On Jun 4, 2008, at 9:58 AM, Paul Pedriana wrote:
> Thanks for the response. I'm sorry, and perhaps I misunderstand, but
> I believe your statement about inline operator new is incorrect.
> Unless I misunderstand you, what you say is not supported by any
> existing compiler nor is it supported by the C++ language standard.
> In summary, the 'inline' keyword does not negate or obviate the One
> Definition Rule. You can demonstrate the problem with the code
> below. Feel free to correct any misunderstanding that I may have of
> your explanation.
You are right that the presence of a declaration or inlining do not
affect the behavior of overridden global operator new, other than via
possible implementation-specific quirks (because compilers are not
required to detect ODF violations).
However, I am not aware of any platforms where an overridden operator
new would have effect across a DLL boundary (note that the C++
standard doesn't talk about dynamic linking at all). So, this is only
an issue if you link WebCore to your application statically, or
specifically export operator new from your DLL. There is no need to do
the latter, and the former sounds like a violation of LGPL to me. If
your platform does not support dynamic linking, or you cannot use it
for some other reason, you may want to investigate the legal
feasibility of using LGPL-licensed code in your projects before
pursuing technical solutions.
> Thus you could use WC_NEW("WebCore/page") to flag the memory
> as belonging to that subsystem. This is invaluable in identifying
> memory, producing subsystem metrics, optimizing memory coherence, and
> deducing memory leaks (though other means also help find leaks).
So far, we've been quite happy using platform tools for memory
debugging. Personally, I do not think that explicitly tagging memory
in this way would be cost-effective, although this is certainly not
out of the question.
- WBR, Alexey Proskuryakov
More information about the webkit-dev