On Sun, 21 Sep 2008 05:57:06 -0700 (PDT), Nash Nipples <[EMAIL PROTECTED]> wrote: > thanks for making it even more clear to me. > actually what i meant was this: > > void function(void){ > char *p; > p = malloc(1); > } > int main(void){ > while (1){ > function(); > /* in the end of this function function() > * the memory is still allocated > * even when the only pointer who knows its address > * does not longer exist > * which is why we have to free() the memory > * during the application runtime > * to avoid it from growing to ridiculous size > */ > } > }
This won't throw SEGV in free() because, well, it never calls free(), but it leaks memory like mad :) > but even if you kill -SEGV `pgrep this` (Segmentation fault (core > dumped) the memory is getting freed anyway (presumably by the glorious > kernel). which you can see dynamicly by typing top in the console. Yes. When a process terminates, the kernel dismantles and releases all its 'mapped memory areas', including the heap where malloc()'ed memory comes from. _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"