Skip to content
Commit fa6a47bf authored by Jian Zhang's avatar Jian Zhang Committed by Jayanth Othayoth
Browse files

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: default avatarJian Zhang <zhangjian.3032@bytedance.com>
parent 41167a2a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment