malloc'd memory after a process is killed

malloc'd memory after a process is killed

Post by Chad Dupu » Thu, 19 Jul 2001 00:18:12



A quick question about using malloc() in AIX.  If, after you have used
malloc() to allocate some memory and then the process is killed before
that memory is freed, does AIX do any sort of memory cleanup or does
that memory remained allocated (unavailable to another program) until
the system is restarted?

Thanks,
Chad Dupuis

 
 
 

malloc'd memory after a process is killed

Post by Gary R. Hoo » Thu, 19 Jul 2001 05:46:11



> A quick question about using malloc() in AIX.  If, after you have used
> malloc() to allocate some memory and then the process is killed before
> that memory is freed, does AIX do any sort of memory cleanup or does
> that memory remained allocated (unavailable to another program) until
> the system is restarted?

It's virtual, it belongs to the process (and aside from paging space
issues
doesn't affect any other process) and when the process dies the VM in
use by the process disappears.

This should apply to any Unix system.

--
Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE
________________________________________________________________________

 
 
 

malloc'd memory after a process is killed

Post by Mike m » Thu, 19 Jul 2001 03:54:49


Yes, AIX does do a memory cleanup after the process is killed. That's a
property that UNIX programmers rely upon far too often.

> A quick question about using malloc() in AIX.  If, after you have used
> malloc() to allocate some memory and then the process is killed before
> that memory is freed, does AIX do any sort of memory cleanup or does
> that memory remained allocated (unavailable to another program) until
> the system is restarted?

> Thanks,
> Chad Dupuis

 
 
 

malloc'd memory after a process is killed

Post by Christer Pal » Fri, 20 Jul 2001 01:17:07



> Yes, AIX does do a memory cleanup after the process is killed. That's a
> property that UNIX programmers rely upon far too often.

It's perfectly fine to make this assumption, i.e. no need to free()
anything before exit()'ing. Nothing wrong with that really. Same goes
with close()'ing files, etc...

That doesn't mean that it's fine to keep allocating memory without
freeing it when it's not needed anymore, or fail to clean up resources
that are not cleaned by the system such as shared memory, temp files,
etc...

--
Christer Palm