How to avoid memory leak when user press ctrl+c under linux?

前端 未结 7 2008
眼角桃花
眼角桃花 2020-12-29 15:28

In my program written with C and C++, I will new an object to fulfill the task, then delete the object.

At the moment after new object but before delete object, if t

7条回答
  •  醉梦人生
    2020-12-29 15:55

    If you allocated any SYSV Shared Memory Segments using shmget(2) then you must clean up after yourself with shmctl(2).

    If you allocated any POSIX Shared Memory Segments using shm_open(3) then you must clean up after yourself with shm_unlink(3).

    Both SYSV and POSIX shared memory segments persist past process termination. You can see what persists using the ipcs(1) tool.

    Of course, if you haven't used any SYSV or POSIX shared memory segments, then this is all just noise. :)

提交回复
热议问题