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
qipython: Fixes an object lifetime issue causing a memory leak. #46735
When an `AnyObject` was exposed to Python as a `py::object`, we
previously created wrappers for its properties and signals, that held
the `AnyObject`. This caused a dependency cycle: the object maintained
the properties/signals alive and the properties/signals maintained the
object alive. This led to a memory leak.
This patch changes the properties/signals wrapper types, so that they
hold a weak reference to the object instead. The resulting dependency
graph is that the `AnyObject` Python object holds its properties/signals
Python objects and not the reverse, thus breaking the cycle.
However, this change in turn caused a regression in `ApplicationSession`.
The `ApplicationSession::session()` member function was exposed as a
Python read-only property of the Python `Application` type. The property
getter C++ implementation transformed the `Session` object into a
temporary `AnyObject`, which was then converted into a Python object.
Every access to the property therefore returned a new temporary Python
object. These objects previously leaked (because of the behavior
described above) and were therefore kept accessible. Because of the leak
fix, they are not held anymore and are immediately destroyed unless
stored into a variable.
Consequently this patch also reworks the `ApplicationSession` type
exposed in Python so that it now holds the Python object that holds the
`AnyObject` which itself holds the `Session`. This ensures that this
`Session` Python object is persistent as long as the `Application`
instance is alive.
Change-Id: Id1d39be6ced9208a23ae53707d1ef4d466029c68
Reviewed-on: http://gerrit2.aldebaran.lan/1784
Reviewed-by: jmonnon <jmonnon@aldebaran.com>
Reviewed-by: philippe.martin <philippe.martin@softbankrobotics.com>
Tested-by: vincent.palancher <vincent.palancher@softbankrobotics.com>
0 commit comments