Skip to content

fix: ensure external memory adjustments are balanced - #33266

Merged
codebytere merged 1 commit into
electron:mainfrom
dsanders11:fix-native-image-external-memory-balance
Mar 16, 2022
Merged

codebytere merged 1 commit into
electron:mainfrom
dsanders11:fix-native-image-external-memory-balance

Conversation

@dsanders11

Copy link
Copy Markdown
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 recently 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 recently label Mar 15, 2022
@codebytere
codebytere merged commit 652680e into electron:main Mar 16, 2022
@release-clerk

release-clerk Bot commented Mar 16, 2022

Copy link
Copy Markdown

Release Notes Persisted

Fixed incorrect external memory allocation tracking in nativeImage module

@trop

trop Bot commented Mar 16, 2022

Copy link
Copy Markdown
Contributor

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

trop Bot commented Mar 16, 2022

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented Mar 16, 2022

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented Mar 16, 2022

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented Mar 16, 2022

Copy link
Copy Markdown
Contributor

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

@trop

trop Bot commented Mar 16, 2022

Copy link
Copy Markdown
Contributor

@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.

3 participants