This is the mail archive of the
mailing list for the Cygwin project.
Re: memory leak in gethostbyaddr() ?
- From: "Gareth Pearce" <tilps at hotmail dot com>
- To: cygwin at cygwin dot com
- Date: Tue, 03 Sep 2002 05:59:08 +0000
- Subject: Re: memory leak in gethostbyaddr() ?
Hmm I thought this would be an obvious thing - its returning a pointer to
memory you didnt give it so therefore your supposed to clean up. However
this is not always the case so I thought I would check SUS ... and I was
supprised to find that it was specifically ambiguous?? I fail to see how a
specification can get away with saying the return 'Might' point to static
memory. But indeed it does... wierd. and SUSv3 says that gethostbyaddr is
obsolete and getaddrinfo is recommend to be used instead (which looks like
it Doesnt use static memory so your responsible for cleaning it up).
I'm use gethostbyaddr() for name resolving. But when I'm call
gethostbyaddr() many times, the memory, allocated by the program is growing
(see attach). Why?
(not using static memory is good in a way, dont have to worry about multiple
calls or threads causing significant problems)
So I suspect (but havent confirmed :P) that cygwin takes the 'doesnt use
static memory' path available in the specification, and you just need to
Not hard to test, it will almost certainly crash very quickly if its using
static memory and you start freeing it inside the loop.
Send and receive Hotmail on your mobile device: http://mobile.msn.com
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html