What Unix do with unused shared memory?

Hello,

When creating shared memory in C, should be remove shared memory with shmctl function when don't need it. If it didn't remove, occupied shared memory stay and remain.

If we create shared memory repeatedly without removing unusable shared memory, /dev/shm will full.

Does Unix or Linux distributions do action to them? For example if a shared memory has 0 shm_nattch and wasn't used in long time, remove them.

From the shmget man page. It means you must remove them or they will persist.

1 Like