watch: fix memory leak in Watch class
See systemd manunal[0], ``` If the second parameter of sd_event_add_io() is NULL no reference to the event source object is returned. In this case the event source is considered "floating", and will be destroyed implicitly when the event loop itself is destroyed. ``` The Watch class should release the event source object when destructing the Watch object. Tested: 1. Run CreateDump Stress Test ``` while true; do busctl call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 0; sleep 200; done ``` 2. run the command to monitor the memory heap size of dump-manager, and no memory leak found. ~# watch -n 10 "cat /proc/[PID]/smaps | grep heap -A 4 | grep ^Rss" [0]: https://www.freedesktop.org/software/systemd/man/latest/sd_event_add_io.html Change-Id: I530bda40a7a7307ee87f03a24c242dde4eae2b14 Signed-off-by:Jian Zhang <zhangjian.3032@bytedance.com>
Loading
Please register or sign in to comment