[webkit-dev] WebKit memory management?

Mark Rowe mrowe at apple.com
Tue Jun 3 20:21:39 PDT 2008

On 03/06/2008, at 19:58, Paul Pedriana wrote:

> As I have mentioned recently on this list, I am investigating the
> possibility of porting WebKit to work within games on gaming  
> platforms.
> Recent help on this has been greatly appreciated and I am going to try
> to stick with WebKit as opposed to Mozilla/Gecko.
> A major consideration for the usage of libraries in general on gaming
> and embedded platforms is that their memory usage be controllable. The
> application should be able to set aside a block of RAM and have the
> library use that block of RAM via a user-supplied memory allocator. At
> no time should the library attempt to use any other memory nor use its
> own means to access the user-provided memory. This pattern of library
> development is very important, and most professional commercial  
> library
> software follows this pattern (including all commercial peers of
> WebKit). I am wondering how I might achieve this with WebKit.

WebKit uses a derivative of Google's high-performance Thread Caching  
Malloc (<http://google-perftools.googlecode.com/svn/trunk/doc/tcmalloc.html 
 >) for the majority of allocations.  We've tuned the allocator to add  
further performance gains over the system allocators on Mac and  
Windows, and have recently made further improvements to ensure unused  
memory is returned to the system.  Within JavaScriptCore and WebCore  
we overload "operator new" and "operator delete" in terms of our  
"fastMalloc" and "fastFree" functions to ensure all C++ object  
allocations go via this allocator (<http://trac.webkit.org/browser/trunk/JavaScriptCore/wtf/FastMalloc.h 
 >).  The few direct calls to "malloc" and "free" within  
JavaScriptCore and WebCore are also made via our wrapper functions.   
This should make it straightforward to substitute your own custom  
allocator in place of WebKit's if it would better suit your target  

Kind regards,

Mark Rowe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2413 bytes
Desc: not available
Url : http://lists.webkit.org/pipermail/webkit-dev/attachments/20080603/e8f3b6af/attachment.p7s 

More information about the webkit-dev mailing list