Skip to content

OutOfMemory when disposing images due to many copies of image in GC.operations #3296

@meyertom

Description

@meyertom

Describe the bug
We are using dynamic images that are then displayed on a Canvas for a process-state visualization.
The addition of the operations list in GC for ImageOperations is a problem in our case. the list contains all (Image)Operations since the opening of the Window, leading to a very long list of operations acting on the same image(s). When such an image is disposed, a copy of the image is made for every ImageOperation (acting on this image) contained in the operations list of the gc.
In our setup this leads to thousands of copies of a single image, that are created on disposal of the image.

Inverting the disposal order is not an option in our case,

I have no clear understanding on when the operations list is used in GC (it seems to be used only when GC. refreshFor(Drawable drawable, ImageHandle imageHandle is invoked. Therefore I'm not in a position at the moment to suppose a solution for the problem.
Removing old image operations from operations , when the image that is drawn and the boundaries are already contained in operatons might be an idea but the logic when an operation in operations might be removed might get complicated.

To Reproduce
Create an image.
Draw the image to a Canvas
modify the image
redraw the image in the Canvas.
dispose the image
This leads to two copies of the image beeing created in the ImageOperations of the GC.

Expected behavior
Only operations that help determine the state of the Drawable should remain in GC.operations.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)

  2. JRE/JDK version

Version since
We encontered this problem whe switching to SWT 4.39, but te probelm exists since the introduction of the operations list in GC.

Workaround (or) Additional context
Add any other context about the problem here.
Any known workarounds for the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    WindowsHappens on Windows OS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions