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

fix: ensure external memory adjustments are balanced #33266

Merged

Conversation

dsanders11
Copy link
Member

Description of Change

This change is modeled after how it is done for ImageBitmap in Chromium.

The current code has the potential to make unbalanced adjustments, decrementing more memory than it has incremented, which messes with the overall tracking. Currently adding a representation to an empty nativeImage doesn't increase the external memory count, but the destructor decrements it, leading to a net negative. If you run that in a loop, you'll eventually turn the total external allocated memory count negative.

I think there are improvements to be made on the general tracking here, especially with multiple representations, but that requires more research and I wanted to start by fixing the bug here which can impact the total external allocated memory count.

cc @miniak

Checklist

Release Notes

Notes: Fixed incorrect external memory allocation tracking in nativeImage module

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Mar 13, 2022
@dsanders11 dsanders11 added the semver/patch backwards-compatible bug fixes label Mar 15, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Mar 15, 2022
@codebytere codebytere merged commit 652680e into electron:main Mar 16, 2022
@release-clerk
Copy link

release-clerk bot commented Mar 16, 2022

Release Notes Persisted

Fixed incorrect external memory allocation tracking in nativeImage module

@trop
Copy link
Contributor

trop bot commented Mar 16, 2022

I was unable to backport this PR to "15-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot removed the target/15-x-y label Mar 16, 2022
@trop
Copy link
Contributor

trop bot commented Mar 16, 2022

I was unable to backport this PR to "16-x-y" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Contributor

trop bot commented Mar 16, 2022

I have automatically backported this PR to "18-x-y", please check out #33305

@trop
Copy link
Contributor

trop bot commented Mar 16, 2022

I have automatically backported this PR to "17-x-y", please check out #33306

@trop
Copy link
Contributor

trop bot commented Mar 16, 2022

@dsanders11 has manually backported this PR to "15-x-y", please check out #33311

@trop
Copy link
Contributor

trop bot commented Mar 16, 2022

@dsanders11 has manually backported this PR to "16-x-y", please check out #33312

bavulapati pushed a commit to bavulapati/electron that referenced this pull request Apr 29, 2022
@dsanders11 dsanders11 deleted the fix-native-image-external-memory-balance branch July 16, 2022 00:02
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants