Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.programmer > #1195
| From | Rainer Weikusat <rweikusat@mssgmbh.com> |
|---|---|
| Newsgroups | comp.unix.programmer |
| Subject | Re: the usage of getaddrinfo() |
| Date | 2011-08-28 17:18 +0100 |
| Message-ID | <87liud7bnk.fsf@sapphire.mobileactivedefense.com> (permalink) |
| References | <3e76da03-f115-45da-a1d3-fb3b4d35de56@glegroupsg2000goo.googlegroups.com> <87ty97m2o7.fsf@sapphire.mobileactivedefense.com> <37573d22-5874-46c4-b354-695e04a50d53@glegroupsg2000goo.googlegroups.com> <j387vv$cnm$1@reader1.panix.com> <j393u8$mq0$1@usenet01.boi.hp.com> |
Rick Jones <rick.jones2@hp.com> writes: > John Gordon <gordon@panix.com> wrote: >> In <37573d22-5874-46c4-b354-695e04a50d53@glegroupsg2000goo.googlegroups.com> >> wy <warmyouth@gmail.com> writes: >> > So, if a process called malloc(), and forgeted to free the memory, >> > then after the termination of the process, the memory will still be >> > freed automatically? >> Yes. > > Though, you should not rely on that too heavily. > > If your program makes only the one getaddrinfo() call, not doing the > freeaddrinfo() is probably OK. However, if your program might make > many getaddrinfo() calls and is going to run for some length of time, > your program could end-up reaching the limit of the memory it would be > allocated and crash if you don't do the freeaddrinfo() calls as you > go. It is also generally a good idea to reuse memory which has already been used instead of continuing to use 'fresh memory': Modern computers rely heavily on cacheing in order to achieve good performance both regarding memory content and memory addresses. Unless you are an orthodox C++ (hundreds of M of RSS) or - heaven forbid - even a Java (RSS ::= 'maximum size of the virtual address space'), where you really don't need to worry about the efficiency of your code because 'all was already lost before you started', it makes sense to be parsimonious with respect to memory usage even if there is no risk to ever run out of it.
Back to comp.unix.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
the usage of getaddrinfo() wy <warmyouth@gmail.com> - 2011-08-24 00:43 -0700
Re: the usage of getaddrinfo() Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-24 13:09 +0100
Re: the usage of getaddrinfo() wy <warmyouth@gmail.com> - 2011-08-26 01:25 -0700
Re: the usage of getaddrinfo() David Schwartz <davids@webmaster.com> - 2011-08-26 02:54 -0700
Re: the usage of getaddrinfo() John Gordon <gordon@panix.com> - 2011-08-26 13:44 +0000
Re: the usage of getaddrinfo() Rick Jones <rick.jones2@hp.com> - 2011-08-26 21:41 +0000
Re: the usage of getaddrinfo() Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-28 17:18 +0100
Re: the usage of getaddrinfo() John Gordon <gordon@panix.com> - 2011-08-24 17:29 +0000
csiph-web