[webkit-dev] Questions regarding memory debugging

Holger Freyther zecke at selfish.org
Tue Mar 9 20:56:27 PST 2010


HI All,

I'm currently running the iexploder tests on GtkLauncher and I'm observing a 
growth in memory usage of that process. I have used the GNOME memprof utilitiy 
to look at it and the best candidate for the "leak" is SharedBuffer::append 
which will allocate memory.

Now SharedBuffer is refcounted and can only "leak" if someone is holding a 
reference to it and this is where stuff gets tricky. Besides manually searching 
the tree and adding printf's all over has anyone found a better way of doing 
this?

At the OpenBSC GSM Project we are using this C library talloc. With talloc 
every allocation is happening inside a (hierachical) context and at runtime we 
can send a SIGUSR1 one to the application and the memstatistics are dumped
on the console. I have attached an example output so you guys can see it.

I wonder if such a thing would make sense in a debug build as well? I wonder
if we could change the common Class::create methods to take a context, or
at least an area (Render, Network, Platform) and if these get created in a 
special debug build we add these objects to a list for these contexts and we
can dump the information... e.g. # of allocated bytes, ref count and such? 
Does this sound crazy or too invasive?

comments?
-------------- next part --------------
talloc report on 'vty' (total  26810 bytes in 2351 blocks)
    save_cwd                       contains     37 bytes in   1 blocks (ref 0) 0x92d18d0
    vty_command                    contains  15093 bytes in 1180 blocks (ref 0) 0x92d1898
    vty_vector                     contains  11680 bytes in 1169 blocks (ref 0) 0x92d1860
full talloc report on 'openbsc' (total  85562 bytes in  54 blocks)
    struct ia_e1_handle            contains     60 bytes in   1 blocks (ref 0) 0x92f74a8
    telnet_connection              contains      1 bytes in   1 blocks (ref 0) 0x92c50a0
    struct gsm_network             contains  84860 bytes in   5 blocks (ref 0) 0x92c3830
        struct gsm_bts                 contains  84604 bytes in   2 blocks (ref 0) 0x92f7ad8
            struct gsm_bts_trx             contains  82092 bytes in   1 blocks (ref 0) 0x92f84e0
        OpenBSC                        contains      8 bytes in   1 blocks (ref 0) 0x92c51f8
        OpenBSC                        contains      8 bytes in   1 blocks (ref 0) 0x92c2cd0
    counter                        contains    500 bytes in  26 blocks (ref 0) 0x92ac568
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c6a78
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b2ae8
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b2aa0
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b2a58
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b2a10
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b29c8
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b2980
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b2938
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c2c10
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c2bc8
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c2b80
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c2b38
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c2af0
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b3b48
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b3b00
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b3ab8
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b3a70
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92ae140
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92ae0f8
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92ae0b0
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b0250
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b0208
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c5058
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92b0178
        struct counter                 contains     20 bytes in   1 blocks (ref 0) 0x92c5110
    trau_upq_entry                 contains      0 bytes in   1 blocks (ref 0) 0x92ac530
    trau_map_entry                 contains      0 bytes in   1 blocks (ref 0) 0x92ac4f8
    transaction                    contains      0 bytes in   1 blocks (ref 0) 0x92ac4c0
    subch_txq_entry                contains      0 bytes in   1 blocks (ref 0) 0x92ac488
    signal_handler                 contains    140 bytes in   8 blocks (ref 0) 0x92ac450
        struct signal_handler          contains     20 bytes in   1 blocks (ref 0) 0x92f7a20
        struct signal_handler          contains     20 bytes in   1 blocks (ref 0) 0x92f1488
        struct signal_handler          contains     20 bytes in   1 blocks (ref 0) 0x92ac6c0
        struct signal_handler          contains     20 bytes in   1 blocks (ref 0) 0x92ac678
        struct signal_handler          contains     20 bytes in   1 blocks (ref 0) 0x92ac630
        struct signal_handler          contains     20 bytes in   1 blocks (ref 0) 0x92ac5e8
        struct signal_handler          contains     20 bytes in   1 blocks (ref 0) 0x92ac5a0
    paging_request                 contains      0 bytes in   1 blocks (ref 0) 0x92ac418
    gsm_call                       contains      0 bytes in   1 blocks (ref 0) 0x92ac3e0
    subscr_request                 contains      0 bytes in   1 blocks (ref 0) 0x92ac3a8
    subscriber                     contains      0 bytes in   1 blocks (ref 0) 0x92ac370
    sms                            contains      0 bytes in   1 blocks (ref 0) 0x92ac338
    loc_updating_oper              contains      0 bytes in   1 blocks (ref 0) 0x92ac300
    bs11_file_list_entry           contains      0 bytes in   1 blocks (ref 0) 0x92ac2c8
    msgb                           contains      0 bytes in   1 blocks (ref 0) 0x92ac290



More information about the webkit-dev mailing list