cpp-ipc icon indicating copy to clipboard operation
cpp-ipc copied to clipboard

clean up on destruction

Open zomboir opened this issue 4 years ago • 3 comments

Due to statically declared objects, some artifacts aren't removed from /dev/shm when the ipc::chan object is destroyed.

Steps to reproduce: Attached sample code: ipc_plain.cpp.txt

  • Place breakpoint at line 35
  • Observe contents of /dev/shm: __IPC_SHM____CHUNK_INFO__1383424 (42MBytes) __IPC_SHM____CA_CONN __

The two files are deleted only when main() returns.

zomboir avatar Oct 04 '21 09:10 zomboir

Adding diff file here, as the PR on github doesn't show the differences properly: git diff --ignore-space-at-eol src/libipc/ipc.cpp >src/libipc/ipc.cpp.diff.txt ipc.cpp.diff.txt

zomboir avatar Oct 04 '21 10:10 zomboir

I will check this out tomorrow.

mutouyun avatar Oct 09 '21 02:10 mutouyun

  • about the modification of cc_id_

This is a nice fix, and the connection-info id really doesn't need to worry about global uniqueness.

  • about the modification of destroy

'chunk_storages' is a simple memory pool, there is no binding relationship between it and the ipc handle. So if you clean up 'chunk_storages' when an IPC handle is destroyed, you may cause problems for other IPC handles in the same process.

mutouyun avatar Oct 10 '21 05:10 mutouyun