[webkit-dev] WebKit memory management?
chrisb at adobe.com
Wed Jun 4 14:37:40 PDT 2008
I have two "clever" ideas, which might be bad ones, that would not involve massive changes to the existing code:
1) Have a global variable that points to context that code in the platform layer ( including things like malloc, free, operator new, and operator delete ) can use. Then have a class that is instantiated on the stack before any call in to WebKit. The constructor for this class would copy the value of the global into a member variable and set the global variable to point to the correct context. The destructor for this class would restore the previous value of the global variable store in the member variable.
2) Use llvm ( http://llvm.org/) to create a C++ compiler that compiles WebKit into a C or C++ program ( you could also directly generate machine code ) where every function ( including class methods ) in webkit has an addition argument that points to the "global" state. The generated code would reference all global state ( including static variables in classes and function ) relative to this additional argument. The client of webkit would have to allocate a buffer large enough to contain this global state ( the compiler would have to figure out how big the buffer needed to be ) and pass it into all WebKit entry points. You'd be able to have multiple copies of WebKit's global state in the same process. You'd have to hooks you need to destroy an instance of WebKit such that you know all resources given to WebKit have been destroyed. Similar to the way an OS can tear down a process and reclaim an resources give to that process.
From: webkit-dev-bounces at lists.webkit.org [mailto:webkit-dev-bounces at lists.webkit.org] On Behalf Of Maciej Stachowiak
Sent: Wednesday, June 04, 2008 12:49 PM
To: Paul Pedriana
Cc: WebKit-Dev; Mark Rowe
Subject: Re: [webkit-dev] WebKit memory management?
I can think of two possible solutions:
2) Require allocation to happen in some way other than "new" and "delete", for instance always with template functions. Then perhaps we could use #defines to make any actual use of "new" and "delete" an error.
Either of these would be a large change to the source, especially #2 (#1 only needs to affect classes with no other subclass and the few places we use new on non-class types to make arrays).
Perhaps someone else has a more clever idea.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev