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
If code regarding memory pressure can be moved into the SafeHandle explicit disposal of an instance is not needed anymore and make the code more robust. Currently Pixbuf / Bytes have an explicit Dispose method. If this method is not used by the user, the memory pressure gets not released. Putting the Memory pressure into the safe handle ensures that the pressure is released once the instance is freed. This needs some manual hook inside the SafeHandle as there is no unified possibility to detect memory pressure.
One way to put it into the SafeHandle is to have an optional partial method which can be used to add custom code to the generated code. -> This is probably not possible because the handle get's set into the SafeHandle after the constructor is run. So it is not possible to calculate the pressure as no pointer is available.
Alternatively the release of the memory pressure could be somehow part of the object and not of the SafeHandle, thus being one level up in the hierarchy.. E.g. if there is some dispose event it could probably be used.
One more alternative (preferred) add a "SetMemoryPressure(bytes)" method to SafeHandles. This safes the memory pressure value and will release it again. The call must be implemented manually on the surrounding type.
If code regarding memory pressure can be moved into the SafeHandle explicit disposal of an instance is not needed anymore and make the code more robust. Currently Pixbuf / Bytes have an explicit Dispose method. If this method is not used by the user, the memory pressure gets not released. Putting the Memory pressure into the safe handle ensures that the pressure is released once the instance is freed. This needs some manual hook inside the SafeHandle as there is no unified possibility to detect memory pressure.
One way to put it into the SafeHandle is to have an optional partial method which can be used to add custom code to the generated code. -> This is probably not possible because the handle get's set into the SafeHandle after the constructor is run. So it is not possible to calculate the pressure as no pointer is available.
Alternatively the release of the memory pressure could be somehow part of the object and not of the SafeHandle, thus being one level up in the hierarchy.. E.g. if there is some dispose event it could probably be used.
One more alternative (preferred) add a "SetMemoryPressure(bytes)" method to SafeHandles. This safes the memory pressure value and will release it again. The call must be implemented manually on the surrounding type.
Might be related to #397.
The text was updated successfully, but these errors were encountered: