Hi Johannes, On Thu, May 22, 2008 at 12:21:51PM +0200, Johannes Hofmann wrote:
Hi,
to see which part of dillo consumes which amount of memory, I hacked together a version of dlib.c that counts memory that was allocated via dMalloc(). A malloc_tag allows to assign the mallocs to specific parts in the code. In the patch below I use malloc_tag = 1 for cache stuff, malloc_tag = 2 for text strings that are passed dw2 and malloc_tag = 0 for everything else. It's fun to see how memory get's allocated and free'd while loading. Here is the output once the huge mysql manual page is loaded:
====> malloc size 5185114 26967623 6602392 0
So that's 6M for text strings, 26M cache and 5M other. Of course there is also all the dw2 stuff that is not taken into account here.
Yes, and dw2 stuff should be the main part...
BTW, textblock delete's the text strings that are allocated using malloc(). That's not allowed and might cause unexpected behaviour on some platforms.
This is clearly a bug. A long time ago I thought of dw2 using dlib. Now dw2 is mainly using its own resources. The simple solution would be to let addText to allocate and delete the string. Another way is to study whether is worth to convert dw2 to dlib. It'd be great if we can have gprof profiling working on dillo again. Then use it to see what is the real impact of some optimizations. A long long time ago (in dillo1), I used to heavily optimize functions to avoid extra strdups. It ended making the code a lot more complex and without any noticeable gain. After that we switched to the simple paradigm of having each function free what it allocated. Can you give a hand at enabling profiling again? -- Cheers Jorge.-