Re: ghashes
- From: Christoffer Gurell <orbit supa nu>
- To: gtk-devel-list gtk org
- Subject: Re: ghashes
- Date: Wed, 28 Mar 2001 13:47:46 +0200
> i see a problem in ghash.c. Mem is allocated from a global GMemChunk which
> never shrinks.. say a preogram spawns 20threads that all create one hash
> each. then ALOT of memory will be allocated and never freed.. a solution
> could be to move the GMemChunk into the GHashTable stuct so that each hash
> has it's own mempool.. this would enable g_hash_table_destroy() to free ALL
> memory associated with a ghash so no memory leaks ..
i've done some mem profiling and indeed with many hashes of large hashes
dmalloc reports a whole bunch of allocations of mem that are never freed..
i've patched my version and put the allocator inside the GHashTable struct
so that each hash has it's own allocator. i could then remove the lock in
ghash.c since there are no longer any global variables. :) . problem is that
if i have a very larga hash it takes TIME to free the allocator when the
hash i destroyed.. this can be helped by allocating 10000 instead of 1024
but this is'nt always desired either.. perhaps we should make it possible to
tell the ghashed how many key's we think it'll hold.. or perhaps make the
allocator allocate more mem each time it needs to..
comments?.. spam ahead :)) ..
/ chrisse
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]