Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move memory pressure into SafeHandle #759

Open
2 of 3 tasks
badcel opened this issue Jan 13, 2023 · 0 comments · May be fixed by #1118
Open
2 of 3 tasks

Move memory pressure into SafeHandle #759

badcel opened this issue Jan 13, 2023 · 0 comments · May be fixed by #1118
Labels
bug Something isn't working
Milestone

Comments

@badcel
Copy link
Member

badcel commented Jan 13, 2023

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.

@badcel badcel added this to the 0.14.0 milestone Sep 1, 2023
@badcel badcel added the bug Something isn't working label Sep 4, 2023
@badcel badcel modified the milestones: 0.14.0, 0.6.0 Aug 13, 2024
@badcel badcel linked a pull request Sep 22, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant