Skip to content

Give ImageMagick's pixel cache back after reading pixels (#2076) - #2079

Draft
cre8ive-marketing wants to merge 1 commit into
KnifeLemon:mainfrom
cre8ive-marketing:fix/2076-raw-memory
Draft

cre8ive-marketing wants to merge 1 commit into
KnifeLemon:mainfrom
cre8ive-marketing:fix/2076-raw-memory

Conversation

@cre8ive-marketing

Copy link
Copy Markdown
Collaborator

Fixes #2076.

RawTone.ToSrgb read the pixels with image.GetPixels().ToByteArray(...) and never disposed the pixel view. An open view keeps ImageMagick's pixel cache alive, so ImportPixels got a new cache and the old one, counted against the memory limit in policy.xml, was never given back. Each RAW file leaked one full picture, and after a few hundred every read failed with cache resources exhausted ... OpenPixelCache/4044 until restart.

  • PixelBytes.Read: reads the bytes through a view that is closed before the caller goes on. Used by every Magick.NET GetPixels().ToByteArray(...) that had no using: RawTone, ImageReader (MIFF), ImageEncoder, Apng, BackdropComposer, Blp, DdsChannelOrder, VtfWriter, ImageTo3DConverter. DdsChannelOrder's one-pixel read gets a using.
  • Test PixelBytesTests.Raw_tones_give_the_pixel_cache_back: 40 × 12 MP through RawTone.ToSrgb under a 256 MB memory + 256 MB disk limit. It fails on main with the same cache resources exhausted error, and passes with the fix. It runs on its own, as the limits are global.
  • CHANGELOG line under 2.6.0 Fixes.

Checked on Windows: Core 2037 pass; Engines 5292 of 5293 and App 3669 of 3671 pass. The 3 failures look unrelated: MediaTests.A_photo_becomes_a_still_video_in_full_colour fails the same way on main here (this machine's ImageMagick can't read the test's hald:8 picture), and the two SliceLabelLayoutTests measure label text with this machine's fonts, which this change doesn't touch. Not checked here: a real batch of NEF files in the app.

…2076)

GetPixels() without using kept the pixel cache alive, so each RAW read leaked
one picture against policy.xml's memory limit until reads failed with
"cache resources exhausted".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Batch RAW → PNG: process memory is never released, conversions fail with "cache resources exhausted" until Filee is restarted

1 participant