Re: Problem with libiberty's hash tables

2008-02-15 Thread Paolo Bonzini
If the latter, of course you could write pointer_map_delete yourself; it might be worthwhile since pointer maps are a tad faster than libiberty hashtabs. It's on my todo list, but I wrote pointer_map for my private work on gcc and it was not needed at the time. But didn't you say the need t

Re: Problem with libiberty's hash tables

2008-02-15 Thread FX Coudert
Sure it's faster this way, but what's wrong with valgrind? ;- valgrind (and mtrace) are OS-specific. Also, tracking memory allocations has other benefits, like allowing to give memory statistics (what are the largest allocations, how much is used for compiler-generated temporaries, etc.).

Re: Problem with libiberty's hash tables

2008-02-15 Thread Jakub Jelinek
On Fri, Feb 15, 2008 at 09:13:34PM +0100, Paolo Bonzini wrote: > > > The structures left at the end > >(which correspond to memory leaks) are then displayed to allow the > >user to fix his leaks. The CPU usage is probably the limiting factor, > >here, as I want to avoid slowing the program down mo

Re: Problem with libiberty's hash tables

2008-02-15 Thread Paolo Bonzini
The structures left at the end (which correspond to memory leaks) are then displayed to allow the user to fix his leaks. The CPU usage is probably the limiting factor, here, as I want to avoid slowing the program down more than necessary. Sure it's faster this way, but what's wrong with valgr

Re: Problem with libiberty's hash tables

2008-02-15 Thread FX
> If you don't need GC and you don't need delete (the latter I can't see > from your example), a pointer_map is much easier to use. I'm going to use it for registering memory allocation: pointers malloc'ed will be registered, along with the source location of the allocation; when freed, I fetch

Re: Problem with libiberty's hash tables

2008-02-15 Thread Paolo Bonzini
FX wrote: Hi all, I've started using libiberty's hashtab in libgfortran for some of my gfortran work to track memory allocations in the library. I store custom structures in a hash table, each structure containing a unique pointer (it is a malloc'ed address) that is used for the hash. When I tra

Re: Problem with libiberty's hash tables

2008-02-15 Thread FX
Ouch... I got it, it indeed was a beginner mistake. Looking through GCC to see how it used these hash tables, I noticed the problem. Sorry for the noise! PS: for posterity, the error was: > /* Register this allocation. */ > a = (allocation_t *) htab_find_slot (tab, p, INSERT); > a->p = p;

Problem with libiberty's hash tables

2008-02-15 Thread FX
Hi all, I've started using libiberty's hashtab in libgfortran for some of my gfortran work to track memory allocations in the library. I store custom structures in a hash table, each structure containing a unique pointer (it is a malloc'ed address) that is used for the hash. When I traverse the ta