You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the IOC terminates, the ports are not given a chance to clean up and release resources. Some resources, like memory, are not problematic: the OS will reclaim the memory of the terminated process. But there are more problematic resources, such as improperly closed connections to devices, that can consume resources on devices themselves.
I have attempted to work around this in my driver by registering a function with epicsAtExit() which deletes the driver, allowing the destructor to clean up. This causes a crash because EPICS does not stop scan threads on IOC exit. This necessitates disabling the port through asynManager before destroying the driver. The IOC no longer crashes on shutdown, but it does print spurious error messages when the scan threads poke the disabled port.
This workaround works well for our use case. It is not very "clean", however, because it leaves dangling references and simply trusts that they will not be used anymore.
Other users have noticed this behavior. The above workaround was proposed and discussed in the linked thread, and steps towards a better solution were outlined by Michael Davidsaver.
The text was updated successfully, but these errors were encountered:
+1 to this being a nice improvement. It would make troubleshooting serious memory leaks in our drivers much easier if we can work towards knowing that the release branches of base, asyn, ADCore, etc. are valgrind memcheck/leak-check clean, without having to sift through tons of "leaks" that are actually just a negligible fixed cost that eventually gets freed up by the OS.
Plus, leaving cleanup work to the OS can mess up some unit test frameworks that destroy and rebuild the same objects for different tests.
When the IOC terminates, the ports are not given a chance to clean up and release resources. Some resources, like memory, are not problematic: the OS will reclaim the memory of the terminated process. But there are more problematic resources, such as improperly closed connections to devices, that can consume resources on devices themselves.
I have attempted to work around this in my driver by registering a function with
epicsAtExit()
which deletes the driver, allowing the destructor to clean up. This causes a crash because EPICS does not stop scan threads on IOC exit. This necessitates disabling the port throughasynManager
before destroying the driver. The IOC no longer crashes on shutdown, but it does print spurious error messages when the scan threads poke the disabled port.This workaround works well for our use case. It is not very "clean", however, because it leaves dangling references and simply trusts that they will not be used anymore.
Other users have noticed this behavior. The above workaround was proposed and discussed in the linked thread, and steps towards a better solution were outlined by Michael Davidsaver.
The text was updated successfully, but these errors were encountered: