This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fix memory leak in gengtype


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/20/11 17:35, Dimitrios Apostolou wrote:

> 
> Plus a whole page which is preallocated by the obstack, if I understand
> correctly. As a result, for each word in the text file we consume 4KB,
> which are never freed.
Plausible.  Though I always thought obstacks would release all the
unused chunks as part of the obstack_free call and the obstack structure
itself was always supposed to be "small".

Regardless of what exactly was leaked, the two locations you identified
were leaking a ton of memory.

> 
>>
>> It turns out there's a similar leak in gengtype.c which is fixed in the
>> same way.
>>
> 
> Nice, thanks for looking deeper into this, I just stopped when memory
> utilisation seemed ok.
It's been so long since I had to think about obstacks and I wasn't sure
the leak was really going to be *that* bad, so I decided to run gengtype
under valgrind to verify leak behavior.

FWIW, the remaining 300K are almost all leaks through the hash tables.
It wouldn't take terribly long to verify the death of the hash tables
and insert a suitable htab_delete call.  It probably doesn't matter
much, but I hate leaving the leak, so I'll probably sit down and learn a
little more about gengtype* so I can safely plug the leak hash table leaks.


> 
> If by PA you mean PA-RISC, I remember when I had access to a Visualize
> C200 with gentoo on. I loved the machine, but it had an important issue:
> it was absolutely random if it would power up, when pressing the power
> button. But as long as we never turned it off, it worked ok :-)
I've got a 715, C240 & R390 in the basement.  The R390 overheats.  The
other two worked when I fired them up several years ago.

Anyway, attached is the patch I ultimately checked in.  Same as yours
with the addition of fixing a similar obstack leak in gengtype.c.

jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNsEmrAAoJEBRtltQi2kC7EykH/2nbMtFrAcorqinQViI9Nvtt
xO7H764lFjTQa4gsKP/gq+RFRM2s8omyI8cgaFABM7kfkFp64ZUspXHXQS/U1PX/
PHlLCxnjmnw/w56VGDRjF8z9MZ30Cc3dU7xfJRUAbRuooYzYrPw5fMivCeQo4axy
+hPEhCHohIOzSjC5+yKnafklfgQdVE1pTc9Cp5LKCTDYAlzvh2vi6FOHf8FF2/1C
Dmqgv5qF8Bpd3tyjXj6+/raTU6RfsGsDcQiQo5fADosjPj+h4iWdoVir3xm4TGoU
mCwsAoywawk2tPBvlbHAMEg5fiia3qjQ73Pmt2Z62WcK/C+BaZJnj4Or/iZ6Xao=
=2JFI
-----END PGP SIGNATURE-----

Attachment: P
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]