Skip to main content
aboswrt
Known Participant
Nov 27, 2026 1:00 AM UTC
Open for Voting

Lightroom Classic 16 SDK: LrView "picture" view keeps about 123 MB per megapixel each time it shows an image, not freed on close

Each time an LrView picture view displays a JPEG file, Lightroom Classic's memory grows by about 123 MB per megapixel of the image, and closing the dialog doesn't give it back. It happens when a dialog opens with the picture's value set, and again each time the value changes in an open dialog. In my runs the memory was still in use several minutes later, and quitting Lightroom was the only way I found to get it back.

I found it while building a plugin that shows a 3×3 grid of Lightroom renders in picture views. Each reopen of its dialog cost about 0.9 GB. After about ten reopens the Mac kernel-panicked (watchdog timeout, low swap space), and the panic report lists Lightroom at 11.8 GB, by far the largest process on a 16 GB machine. That was on 15.4.1; it still happens on 16.0.1.

Environment: Lightroom Classic 16.0.1, macOS 15.8.2 (24H232), MacBook Pro M1, 16 GB. I haven't tried Windows.

Minimal code (a menu script; set the two paths to any two large JPEGs, for example 2880×1920, and watch Lightroom in Activity Monitor):

local LrBinding = import 'LrBinding'
local LrDialogs = import 'LrDialogs'
local LrFunctionContext = import 'LrFunctionContext'
local LrTasks = import 'LrTasks'
local LrView = import 'LrView'

local FIRST_JPEG = '/path/to/first.jpg'
local SECOND_JPEG = '/path/to/second.jpg'
local SWITCH_COUNT = 2

LrFunctionContext.postAsyncTaskWithContext('picture-leak', function(context)
local properties = LrBinding.makePropertyTable(context)
properties.image = FIRST_JPEG
local viewFactory = LrView.osFactory()
local contents = viewFactory:column {
bind_to_object = properties,
viewFactory:picture { value = LrView.bind('image'), width = 1074, height = 716 },
}
local isOpen = true
LrTasks.startAsyncTask(function()
for switchNumber = 1, SWITCH_COUNT do
LrTasks.sleep(2)
if not isOpen then return end
properties.image = (switchNumber % 2 == 1) and SECOND_JPEG or FIRST_JPEG
end
end)
LrDialogs.presentModalDialog { title = 'Picture leak', contents = contents }
isOpen = false
end)

With two 2880×1920 JPEGs on 16.0.1, Lightroom went from about 0.9 GB to 1.6 GB on the open, peaked at 3.9 GB during the two switches, and settled at 2.97 GB: about 680 MB kept for each image shown, including the second switch, back to the file already shown. None of it was freed when the dialog closed.

A plugin that does this with memory logging and safety stops is attached in the first reply.

Steps to reproduce with the attached plugin (no catalog access; macOS only, since it reads memory with pgrep and top):

  1. Quit and reopen Lightroom.
  2. File > Plug-in Manager > Add, and pick picture-leak.lrdevplugin.
  3. Library > Plug-in Extras > Run picture leak repro, and click Continue at the warning (the run uses up to 3 GB until Lightroom quits).
  4. Leave it for about 20 seconds. The dialog opens and closes by itself, and the plugin logs Lightroom's memory (phys_footprint, the figure Activity Monitor shows, read with top, in MiB) after each step.

The plugin's dialog holds a single 1074×716 picture view. It opens three times:

  • once with the picture bound to an empty value, as a control;
  • once with a literal value from _PLUGIN:resourceId, with no binding or property table;
  • once with the picture bound to the path of a 2880×1920 JPEG, then, with that dialog still open, switched to a second 2880×1920 JPEG and back to the first.

On my laptop Lightroom's standard previews are 2880×1920 (Catalog Settings > Standard Preview Size: Auto (2880px)), and that is the size requestJpegThumbnail returned when my plugin asked for a render to fill a view this size. My plugin shows those renders from temp files, so it has to bind the picture to absolute paths.

Expected: memory goes up while an image is shown and comes back down when it is replaced or the dialog closes.

Actual (Lightroom Classic 16.0.1, from the plugin's log, Lightroom freshly started):

start: 1071 MB (Lightroom pid 87134)
Empty: bound, no image: 1054 MB (-17 MB)
Fixed: literal resourceId, no binding, 2880x1920 JPEG: 1753 MB (+699 MB)
Cycle: bound path, first 2880x1920 JPEG: 2430 MB (+677 MB)
Cycle: switched to a second 2880x1920 JPEG: 4018 MB (+1588 MB)
stopping before "Cycle: switched back to the first JPEG (same file again)": predicted growth 4535 MB passes the 3200 MB limit

The empty picture costs nothing. The literal resourceId value with no binding costs about 700 MB, the same as the bound path, so the binding and property table aren't the cause. The switch in the open dialog read about 1.6 GB (15.4.1 gave +1625 MB). That reading is taken 2 seconds after the switch, and it looks like a temporary peak: with the minimal code above, memory went over the kept amount by about 1 GB during the switches and came back down a few seconds later. The plugin then stopped itself before the last step to stay under its 3.2 GB limit.

The same run on 15.4.1:

start: 899 MB (Lightroom pid 62132)
Empty: bound, no image: 884 MB (-15 MB)
Fixed: literal resourceId, no binding, 2880x1920 JPEG: 1589 MB (+705 MB)
Cycle: bound path, first 2880x1920 JPEG: 2291 MB (+702 MB)
Cycle: switched to a second 2880x1920 JPEG: 3916 MB (+1625 MB)
stopping before "Cycle: switched back to the first JPEG (same file again)": predicted growth 4642 MB passes the 3200 MB limit

The results below are all from 15.4.1. An earlier run of the same cycle, with four different 2880×1920 JPEGs (the picture bound through the dialog's bind_to_object, as in the minimal code) and no empty or literal-value steps, gave:

start: 884 MB
Cycle image 1 of 4 shown: 1573 MB (+689 MB)
Cycle image 2 of 4 shown: 2252 MB (+679 MB)
Cycle image 3 of 4 shown: 2928 MB (+676 MB)
Cycle image 4 of 4 shown: 3605 MB (+677 MB)
end, dialog closed: 3604 MB (-1 MB)

That is about 680 MB for each 2880×1920 image (the JPEG files are 190 to 330 KB). A plugin that shows a large render and lets you step through a few variations uses gigabytes within a minute.

Earlier versions of the repro also varied the image and view sizes, one open per step, with Lightroom not freshly started (it was at 1729 MB):

B empty picture, 600x400 view: 1708 MB (-21 MB)
A 1200x800 JPEG, 600x400 view: 1837 MB (+129 MB)
C one dialog, 1200x800 JPEG switched to another, before switching: 1955 MB (+118 MB)
C one dialog, 1200x800 JPEG switched to another, after switching: 2072 MB (+117 MB)
D 2148x1432 JPEG, 600x400 view: 2450 MB (+378 MB)
E 1200x800 JPEG, 1074x716 view: 2585 MB (+135 MB)
end, dialog closed: 2577 MB (-8 MB)
  • An empty picture costs nothing (B).
  • 1200×800 (0.96 MP) cost 118 to 129 MB and 2148×1432 (3.1 MP) cost 378 MB, about 123 MiB per megapixel. The 2880×1920 runs fit the same rate. That is close to 128 bytes per pixel, in case it helps find what is being kept.
  • Changing the image in an open dialog costs about the same as opening one (C). In a second run C's two steps split differently (+162 and +78 MB), with the same total.
  • A view with 3.2 times the area cost 135 MB against 129 MB (E), so the cost follows the image's pixel count and the view's size makes little difference.
  • Showing the same file again costs the same again: opening the dialog twice with the same 1200×800 JPEG cost +126 and +118 MB, and switching back and forth between two files cost about 118 MB every time.

At that rate a full-size 24 MP image would cost about 3 GB each time it is shown (a prediction: an earlier version predicted it and skipped the step to stay under its limit). The first version of the repro, with nine pictures per dialog and more repetitions, took Lightroom to 30 GB, measured from outside Lightroom while it ran.

I haven't found a workaround: a picture leaks on every image it shows, fixed or changing. If there's a way to make a picture release its image, or a different view I should be using to show a JPEG file, I'd like to know.

    7 replies

    johnrellis
    Legend
    Nov 28, 2026 4:56 PM UTC

    Interesting that you found it only rendering part of the image too, I hadn't noticed that in my tests.

     

    My test used a larger photo, 45 MP instead of 24 MP. I chose a larger one on the guess it would provoke a problem more noticeable faster.

     

    In the test script I posted, there’s a boolean “async” set to false that controls whether the image is assigned to the picture control before or after the dialog is presented.  When it’s set to “true”, the entire image displays, though just as slowly and without releasing memory afterward.

    Translate
    johnrellis
    Legend
    Nov 27, 2026 10:02 PM UTC

    [View this post in your web browser. It contains formatting and images that don't appear in email.]

    Somewhat surprising that this goes back to 12? Does that mean essentially no one is using plugins that do this?

     

    I think most plugins that display photos use viewFactory:catalogPhoto() to display photos that are in the catalog, and that almost surely uses the cached preview mechanism (so a completely different code path).

     

    Several of my plugins use viewFactory:catalogPhoto(). I tested them just now and they don’t exhibit the memory problem.

     

    I have just one plugin that uses viewFactory:picture(), which it uses to display tiny PNG graphics of less than 2K pixels each. If the bug is being triggered, the effect is so small as to be unnoticeable.

    Translate
    aboswrt
    aboswrtAuthor
    Known Participant
    Nov 28, 2026 2:01 AM UTC

    ​@johnrellis Thanks, that makes sense. In my case the photos are in the catalog too: it's a develop settings variation plugin showing a 3x3 grid of variations, and each cell is a temporary virtual copy with different settings. So catalogPhoto works, and it's what I've gone back to, but I'd moved to picture for speed:

    - With catalogPhoto a cell always shows its copy's current state, so every click rewrites all 9 copies and LR re-renders all 9, one at a time (about 2-2.5 s on my machine). Going back to a value you've already seen costs the same again. With picture I could save each render from requestJpegThumbnail as a JPEG and show it again instantly.
    - I couldn't recycle copies between cells: a catalogPhoto switched from copy A to copy B kept redrawing whenever A changed, even after setting it to nil in between. So it needs one copy per cell, versus a pool of 4 with pictures.
    - Stacking several catalogPhotos in a cell and toggling visible didn't work either: a catalogPhoto that's hidden when its photo arrives never loads it (every cell drew black).
    - Nothing overlaid on a catalogPhoto shows, so I couldn't dim a cell while it was updating.

    So I was really using picture as a render cache, which is uncommon. With previews at 2880 px every large view cost about 0.7 GB, and a few view switches took LR to 11.8 GB and panicked my 16 GB Mac.

    Interesting that you found it only rendering part of the image too, I hadn't noticed that in my tests.

    Translate
    aboswrt
    aboswrtAuthor
    Known Participant
    Nov 27, 2026 6:54 PM UTC

    The repro plugin from the steps above. Unzip it, then File > Plug-in Manager > Add and pick the picture-leak.lrdevplugin folder. Its README has the details. It only opens a dialog and reads the three JPEGs inside it; it doesn't touch the catalog.

    Translate
    aboswrt
    aboswrtAuthor
    Known Participant
    Nov 27, 2026 12:35 AM UTC

    Each time an LrView picture view displays a JPEG file, Lightroom Classic's memory grows by about 123 MB per megapixel of the image, and closing the dialog doesn't give it back. It happens when a dialog opens with the picture's value set, and again each time the value changes in an open dialog. In my runs the memory was still in use several minutes later, and quitting Lightroom was the only way I found to get it back.

    I found it while building a plugin that shows a 3×3 grid of Lightroom renders in picture views. Each reopen of its dialog cost about 0.9 GB. After about ten reopens the Mac kernel-panicked (watchdog timeout, low swap space), and the panic report lists Lightroom at 11.8 GB, by far the largest process on a 16 GB machine.

    Environment: Lightroom Classic 15.4.1, macOS 15.8.2 (24H232), MacBook Pro M1, 16 GB. The repro is macOS only (it reads memory with pgrep and top), and I haven't tried Windows.

    Steps to reproduce (with the attached plugin, which has no catalog access and only opens a dialog):

    1. Quit and reopen Lightroom.
    2. File > Plug-in Manager > Add, and pick picture-leak.lrdevplugin.
    3. Library > Plug-in Extras > Run picture leak repro, and click Continue at the warning (the run uses up to 3 GB until Lightroom quits).
    4. Leave it for about 20 seconds. The dialog opens and closes by itself, and the plugin logs Lightroom's memory (phys_footprint, the figure Activity Monitor shows, read with top, in MiB) after each step.

    The dialog holds a single 1074×716 picture view. It opens three times:

    • once with the picture bound to an empty value, as a control;
    • once with a literal value from _PLUGIN:resourceId, with no binding or property table;
    • once with the picture bound to the path of a 2880×1920 JPEG, then, with that dialog still open, switched to a second 2880×1920 JPEG and back to the first.

    On my laptop Lightroom's standard previews are 2880×1920 (Catalog Settings > Standard Preview Size: Auto (2880px)), and that is the size requestJpegThumbnail returned when my plugin asked for a render to fill a view this size. My plugin shows those renders from temp files, so it has to bind the picture to absolute paths.

    Expected: memory goes up while an image is shown and comes back down when it is replaced or the dialog closes.

    Actual (from the plugin's log, Lightroom freshly started):

    start: 899 MB (Lightroom pid 62132)
    Empty: bound, no image: 884 MB (-15 MB)
    Fixed: literal resourceId, no binding, 2880x1920 JPEG: 1589 MB (+705 MB)
    Cycle: bound path, first 2880x1920 JPEG: 2291 MB (+702 MB)
    Cycle: switched to a second 2880x1920 JPEG: 3916 MB (+1625 MB)
    stopping before "Cycle: switched back to the first JPEG (same file again)": predicted growth 4642 MB passes the 3200 MB limit

    An earlier run of the same cycle, with four different 2880×1920 JPEGs and no empty or literal-value steps, gave:

    start: 884 MB
    Cycle image 1 of 4 shown: 1573 MB (+689 MB)
    Cycle image 2 of 4 shown: 2252 MB (+679 MB)
    Cycle image 3 of 4 shown: 2928 MB (+676 MB)
    Cycle image 4 of 4 shown: 3605 MB (+677 MB)
    end, dialog closed: 3604 MB (-1 MB)

    That is about 680 MB for each 2880×1920 image (the JPEG files are 190 to 330 KB). A plugin that shows a large render and lets you step through a few variations uses gigabytes within a minute.

    Earlier versions of the repro also varied the image and view sizes, one open per step, with Lightroom not freshly started (it was at 1729 MB):

    B empty picture, 600x400 view: 1708 MB (-21 MB)
    A 1200x800 JPEG, 600x400 view: 1837 MB (+129 MB)
    C one dialog, 1200x800 JPEG switched to another, before switching: 1955 MB (+118 MB)
    C one dialog, 1200x800 JPEG switched to another, after switching: 2072 MB (+117 MB)
    D 2148x1432 JPEG, 600x400 view: 2450 MB (+378 MB)
    E 1200x800 JPEG, 1074x716 view: 2585 MB (+135 MB)
    end, dialog closed: 2577 MB (-8 MB)
    • An empty picture costs nothing (B).
    • 1200×800 (0.96 MP) cost 118 to 129 MB and 2148×1432 (3.1 MP) cost 378 MB, about 123 MiB per megapixel. The 2880×1920 runs fit the same rate. That is close to 128 bytes per pixel, in case it helps find what is being kept.
    • Changing the image in an open dialog costs about the same as opening one (C). In a second run C's two steps split differently (+162 and +78 MB), with the same total.
    • A view with 3.2 times the area cost 135 MB against 129 MB (E), so the cost follows the image's pixel count and the view's size makes little difference.
    • Showing the same file again costs the same again: opening the dialog twice with the same 1200×800 JPEG cost +126 and +118 MB, and switching back and forth between two files cost about 118 MB every time.

    At that rate a full-size 24 MP image would cost about 3 GB each time it is shown (a prediction: an earlier version predicted it and skipped the step to stay under its limit). The first version of the repro, with nine pictures per dialog and more repetitions, took Lightroom to 30 GB, measured from outside Lightroom while it ran.

    I haven't found a workaround: a picture leaks on every image it shows, fixed or changing. If there's a way to make a picture release its image, or a different view I should be using to show a JPEG file, I'd like to know.

     

    Translate
    johnrellis
    Legend
    Nov 27, 2026 7:08 PM UTC

    [View this post in your web browser. It contains formatting and images that don't appear in email.]

     

    I’ve attached stripped down demonstration of the problem. Simply using viewFactory:picture() to display a single 8192 x 5464 JPEG causes LR memory to zoom from 757 MB to 6.1 GB, exactly in line with ​@aboswrt’s observations. It takes about 5 seconds for the dialog to appear, and then it only displays part of the image.  Clearly an inappropriate algorithm is being used.

     

    I tested this in LR 12, with the same buggy behavior.

     

    To reproduce on LR 16.0.1 / Mac OS 26.6.2:

     

    1. Download and unzip the attached “picture-control.zip”.

     

    2. In the unzipped folder’s “picture-control.lua”, change Path to the path of “a.jpg” in the unzipped folder and move the .lua to LR’s Scripts folder. Restart LR.

     

    3. In LR, do Scripts > picture-control. Observe that it takes about 5 seconds for the dialog to appear, and it only displays part of the image:

    4. Observe in Activity Monitor that LR’s memory has zoomed to 6.1 GB.

     

    local Path = "/Users/john/Desktop/picture-control/a.jpg"

    local LrBinding = import "LrBinding"
    local LrDialogs = import "LrDialogs"
    local LrFunctionContext = import "LrFunctionContext"
    local LrTasks = import "LrTasks"
    local LrView = import "LrView"

    local f = LrView.osFactory()
    local async = false

    LrFunctionContext.postAsyncTaskWithContext ("", function (context)
    local prop = LrBinding.makePropertyTable (context)

    if not async then
    prop.image = Path
    else
    LrTasks.startAsyncTask (function()
    LrTasks.sleep (1)
    prop.image = Path
    end)
    end

    LrDialogs.presentModalDialog {title = "Picture leak",
    contents = f:column {bind_to_object = prop,
    f:picture {value = LrView.bind "image", width = 1074,
    height = 716}}}
    end)

     

    Translate
    aboswrt
    aboswrtAuthor
    Known Participant
    Nov 27, 2026 7:27 PM UTC

    Thank you for the independent repro ​@johnrellis . Somewhat surprising that this goes back to 12? Does that mean essentially no one is using plugins that do this? It totally crashed my computer a few times!

    Translate