8388786: [macOS] NSImage leak in GlassPasteboard.m when using images for dnd or clipboard operations - #2222
Conversation
|
👋 Welcome back jpereda! A progress list of the required criteria for merging this PR into |
|
@jperedadnr This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 5 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
beldenfox
left a comment
There was a problem hiding this comment.
I verified that PixelsAttachData creates the NSImage using alloc so it needs to be manually released and other clients of this API do call release. Looks good to me.
kevinrushforth
left a comment
There was a problem hiding this comment.
This looks like a correct fix to me. NSImage::TIFFRepresentation returns a new image and doesn't take ownership of the NSImage, so releasing it is the right thing to do.
This PR releases the NSImage that
SetNSPasteboardItemValueForUtf()in GlassPasteboard.m obtains fromgetImage()in GlassPixels.m. Once the pixel data is used, such image is not longer needed and has to be released, preventing a memory leak.Similar operations in GlassCursor.m and GlassMenu.m that use the same NSImage allocation mechanism, did already release the image in this very same way, so this PR just adds the missing release call to GlassPasteboard.m.
There are no tests included, since this is a pure native objective-c memory leak (retained NSImages), and it can't be tracked down from the Java side, but I have tested manually with Instruments and the Leaks template, with this code snippet in MacPasteboardTest:
calling it repeatedly for some time.
Before the fix:
as shown, the leaks are in
getImagefrom libglass.dylib, that allocates aNSImagewith aCGImage(including same amount of internal data, providers, arrays, snapshots objects).After the fix the leaks are gone:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2222/head:pull/2222$ git checkout pull/2222Update a local copy of the PR:
$ git checkout pull/2222$ git pull https://git.openjdk.org/jfx.git pull/2222/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2222View PR using the GUI difftool:
$ git pr show -t 2222Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2222.diff
Using Webrev
Link to Webrev Comment