[webkit-help] Modifications in FastMalloc.cpp to count memory

Zoltan Horvath zoltan at webkit.org
Wed Sep 14 03:21:06 PDT 2011

On Wed, 14 Sep 2011 11:37:45 +0200, Anton Ebertzeder  
<x47ru.x9090 at googlemail.com> wrote:

> Greetings,


> this is my first post here, so I hope I made no mistakes. I also hope  
> this
> is the correct part of mailinglist.

Yes, this is.

> I would like to use WebKit on an embedded system. For this I need to know
> how much memory the WebKit-Browser needs, especially if JavaScript is  
> used.

We don't use FastMalloc for JSValue so you can't measure JSC memory usage  
through FastMalloc properly.
Based on your system, there should be different ways to measure memory  

> I know it depends on many things, the page I view and so on… I’m only
> interested in a generell overview. To count the memory at all I simply  
> added
> a few lines of code to FastMalloc.cpp in source/JavaScriptCore/wtf
> directory. I added a few lines of code to function
> void* fastMalloc(size_t n) {…}
> I simple write n to a global variable.
> mem_counter_var += n;

With this way you can measure only heap allocated objects. You have to  
consider that FastMalloc.cpp contains two fastMalloc function and  
apparently only 1 is going to be compiled, it depends on conditionals  

> In a next step I subtract frees. The debugging show me that function
> fastMalloc is used permanently, but I can’t find my count variable with
> debugger. I also tried to simple printf the variable each time, but it  
> also
> won’t give any result. In my opinion the modifications are not made. I  
> guess
> that WebKit just copy some files and doesn’t compile the FastMalloc.cpp  
> with
> my modifications

If you modified the right function you should see your variable.

>  My Question is now: Does anyone know how to (re)compile WebKit in such a
> way that my modifications to be considered?

Check that your port is defining USE_SYSTEM_MALLOC=1 or not, and you can  
find the proper fastMalloc function.

> Hope anybody can help :)
> Regards,
> X47ru.x9090
> P.S. Sorry for my bad English



More information about the webkit-help mailing list