Re: Possible Kernel Memory Leak in 2.0.28

David Monro (
Sun, 2 Feb 1997 11:25:19 +1100 (EST)

> In article <>,
> (Alan Cox) wrote:
> >> any rate, this deallocates the memory and stabilized my system.. Is
> >> there any reason why shared memory belonging to defunct processes is
> >> not automatically deallocated?
> >
> >SYS5 designers decided it would be useful to be able to leave this sort of
> >state around for other programs to reopen. Yes its stupid, but we are
> >kind of stuck with it. Gimp should create the shared memory, attach it,
> >delete it and then use (the delete occurs on the end of the last attach)
> >
> Does this mean: If I have running a process which allocated some
> chunks of shared memory, and that process crashes, the shmem won't be
> deallocated ?
Yes and no. The way around this is to create the shm, attatch it and also do
the shmctl(id, IPC_RMID, 0) at creation time. It will then be deallocated when
the last process detatches from it (either explicitly or by exiting).

Unfortunately this doesn't work for semaphore blocks as doing semctl(id, 0,
IPC_RMID, 0) deltes the resource now, not later :-(

> --
> # /AS/ #
> # God save the screen ! #