Camera Raw's hidden scratch files fill the disk while Lightroom runs, and Time Machine keeps them a day longer
- 0 replies
- 9 views
- Translate
Description of Issue
- While editing, Camera Raw pages image tiles out to scratch files named
cr_sdk_<n>_g<NNNN>.tmpin Lightroom's container (~/Library/Containers/com.adobe.mas.lightroomCC/Data/tmp). Each file is unlinked as soon as it's created, so Finder anddunever show it, but its space stays allocated while the file is open. - Camera Raw writes these files in 2 GiB "generations" and closes an old one only when every tile in it has been freed, so a file keeps all of its 2 GiB for as long as any tile in it is live. Camera Raw's own log (
CameraRaw/Logs/Adobe Lightroom Log Latest v0.txtin Lightroom's container) says so:- "Scratch generations in use: 35 old + 1 active (allocated=75152060416 live=26260004864 bytes)": 75.2 GB on disk for 26.3 GB of live tiles.
- In another Lightroom 10.0 session: "69 old + 1 active (allocated=148160790528 live=23405944832 bytes)": 148.2 GB on disk for 23.4 GB of live tiles.
- Measured from outside, one Lightroom process held 35 of these files, 72.9 GB allocated on disk, while the folder showed 27 MB. Thirteen of them were still open 70 to 74 hours after they were created. On another night, one process held 53 files (113.7 GB), and the free space on the disk fell from 92.1 GB to 11.6 GB.
- These figures, 148.2 GB at most, are just the largest we happened to see in a few weeks of captures, not a ceiling. Nothing in the code stops the growth before its 2 TiB hard budget (below), and the space runs out long before that.
- Quitting Lightroom closes the files, but with Time Machine on, that didn't give the space back. Each hourly local snapshot keeps every block that was in use when it was taken, including those of deleted files that were still open. With 69.1 GB of scratch files, quitting the Lightroom changed the free space by −0.01 GB. Deleting the local snapshots, oldest first, freed 70.5 GB only when the last one taken before the quit was deleted. Time Machine keeps hourly snapshots for 24 hours, so the space comes back up to a day after Lightroom quits. The same goes for the generations Camera Raw deletes during a session (it truncates them to 0 and closes them): one that held data when a snapshot was taken stays on disk until that snapshot is deleted.
- What Camera Raw 19.0's code does (cr_tile.cpp; the function names are from its own log strings, the addresses are in the attachment):
- In "multiple files (new method)" mode, scratch is written in generations of up to 2 GiB, one file each.
CreateGenerationopens the file withO_CREAT | O_EXCLand unlinks it straight away. - New blocks come only from the active (newest) generation: from its free list for that size class, or appended at its end (
EnsureActiveGenerationForAppend). AddFreeScratchputs a freed block on its own generation's free list. Free lists of older generations are never used again, and freeing a block returns nothing to the file system: no truncation, no hole punching.- An old generation is deleted (truncated to 0 and closed) only when its last live block is freed. A tile gets its block the first time it's paged out (
PurgeTileData), and keeps it until the tile is destroyed or its contents are discarded. So one long-lived tile keeps a whole 2 GiB file on disk. - The only limit is a hard budget of 2 TiB (
0x20000000000bytes), more than the whole disk.WarnIfTooManyOldGenerationswrites the warning above to Camera Raw's log above 20 old generations;WarnScratchBudgetUsagewarns from 75% of the 2 TiB budget.
- In "multiple files (new method)" mode, scratch is written in generations of up to 2 GiB, one file each.
- The writing is heavy too: macOS's "disk writes" resource report logged 549.76 GB written by Lightroom in 4.2 hours, with Camera Raw's scratch thread in
pwriteas the heaviest stack (92% of samples). - The same problem was reported on Lightroom 9.5 (Camera Raw 18.5): https://community.adobe.com/questions-680/lightroom-desktop-fills-disk-with-hidden-cr-sdk-scratch-files-during-ai-editing-1637054. Camera Raw's log there shows "Scratch generations in use: 22 old + 1 active (allocated=47240720384 live=1115922432 bytes)": 47.2 GB on disk for 1.1 GB of live tiles.
Step-by-step Reproduction Instructions
-
Open Lightroom 10.0. In Terminal, count its scratch files:
lsof -p $(pgrep -x "Adobe Lightroom") | awk '/cr_sdk_/ {n++; s+=$7} END {printf "%d scratch files, %.1f GB\n", n, s/1e9}'Right after launch, there is one file (
g0000), close to 0 GB. -
Edit raw photos in Edit view for an hour: crop, Remove, masks (Brush, and AI masks such as Select Subject and Select People), and the Basic sliders, moving on to the next photo every few minutes. Our library is Canon CR3 files (EOS R5 Mark II, R6 Mark II and R6 Mark III).
-
Every 15 minutes, run the command from step 1. Compare it with what the folder shows, and with the free space:
du -sh ~/Library/Containers/com.adobe.mas.lightroomCC/Data/tmp
df -h /System/Volumes/DataCamera Raw's own count is in its log, once there are more than 20 old generations:
grep "Scratch generations" ~/Library/Containers/com.adobe.mas.lightroomCC/Data/Library/Application\ Support/Adobe/CameraRaw/Logs/Adobe\ Lightroom\ Log\ Latest\ v0.txt -
Stop editing and leave Lightroom open, idle, for a few hours. Run step 3 again: many of the files are still open.
-
Quit Lightroom and run
df -h /System/Volumes/Dataagain. If Time Machine took a local snapshot while the scratch files were open (tmutil listlocalsnapshots /lists them), the free space barely changes: the space comes back when the last snapshot taken before the quit is deleted, 24 hours after it was taken. Without such a snapshot, it should go up by about the scratch files' total when Lightroom quits. -
The snapshot part on its own, without Lightroom, in Terminal (zsh): a 2 GiB file deleted while open, like a scratch file, then a local snapshot, then the file is closed. The space comes back only when that snapshot is deleted. These commands delete only the snapshot they create.
avail() { df -k /System/Volumes/Data | awk 'NR==2 {printf "%.2f GB free\n", $4*1024/1e9}' }
f=$(mktemp) && exec 3<>"$f" && rm "$f"
echo "start: $(avail)"
dd if=/dev/urandom bs=8m count=256 >&3 2>/dev/null
echo "2 GiB written: $(avail)"
out=$(tmutil localsnapshot); echo "$out" | tail -1
date=$(echo "$out" | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}')
exec 3>&-
sleep 10
echo "10 s after closing: $(avail)"
[[ -n "$date" ]] && tmutil deletelocalsnapshots "$date"
sleep 10
echo "10 s after deleting it: $(avail)"
The Expected Result
- Scratch space that Camera Raw no longer uses goes back to the disk while Lightroom runs. For example: allocate from the free blocks of older generations, move the few live blocks out of a mostly empty generation so it can be deleted, or punch holes for freed blocks (
fcntl(F_PUNCHHOLE)on APFS). - Scratch has a limit based on the disk's free space, not 2 TiB. If Lightroom keeps gigabytes of hidden files, it says so where users can see it (Help > System Info, for example).
- Fewer scratch files, open for minutes rather than days. With Time Machine's local snapshots, whatever scratch is on the disk when a snapshot is taken stays allocated until that snapshot is deleted, whatever Camera Raw does with it afterwards.
The Actual Result
- One Lightroom process, started 2026-11-22 at 23:19, used for editing that night (until Nov 23 02:39) and on Nov 24 (00:17–03:18), idle in between and afterwards, quit on Nov 26 at 01:15:
- Nov 23, 00:11–01:58: the scratch files grew by 26.6 GB (1.1 → 27.7 GB), and the free space fell by 28.5 GB (98.2 → 69.7 GB).
- Nov 24, right after Lightroom's command list shows
ag.develop.purge_memorytwice (01:39:17 and 01:39:31): Camera Raw started 11 generations (23.6 GB) in 2 minutes 20 seconds. Its log then climbed from 21 to 35 old generations; at 01:49 it reported allocated=75152060416, live=26260004864 bytes. - Nov 24, 03:15: 35 scratch files open, all deleted: 73.10 GB logical, 72.86 GB allocated on disk (each file's st_blocks, read with
proc_pidfdinfo).duof the folder: 27 MB. It had started 123 generations (g0000–g0122), and started none after that. - Nov 26, 01:15, after two idle days: 33 files open, 69.25 GB logical, 69.12 GB allocated. Thirteen of them (g0000, g0003, g0007, g0008, g0012, g0017, g0019, g0021, g0026, g0031, g0039, g0040, g0046), created in the first session, were 70.6 to 73.9 hours old; none had been written to since Nov 24 00:26.
- Lightroom quit at 01:15:54 (a normal Quit). Free space: 346.196 GB before, 346.185 GB a minute after. No process had a scratch file open any more. Time Machine had 25 local snapshots, hourly from Nov 25 01:03 to Nov 26 01:01, all taken while those files were open.
- Nov 26, 01:47–01:49: the 24 snapshots left (Time Machine had deleted the oldest, then just over 24 hours old) were deleted one by one, oldest first. The first 23 freed 0.03 to 1.29 GB each (5.04 GB in all). The last one, from 01:01, freed 70.48 GB within 13 seconds. Free space: 345.09 → 420.59 GB.
- Without Lightroom, a 2 GiB file opened with
O_RDWR | O_CREAT | O_EXCL, unlinked and written withpwrite: closing it freed 2.15 GB within 5 seconds. With a local snapshot (tmutil localsnapshot) taken while it held data, closing it freed nothing, and neither didftruncate(fd, 0)followed by a close. Deleting that snapshot freed the space (2.17 and 2.16 GB). Step 6's commands gave the same result. - Another process, seen in our captures from 2026-11-15 23:48 to 2026-11-16 04:41, editing with AI masks (skin, subject and background selections), Remove, Brush and crop:
- It started 282 generations by 04:41. At 04:10, 53 files were open: 113.7 GB. Generations g0002, g0005, g0008, g0016 and g0024 were open in every capture from the first one that showed them until 04:41, while 213 later ones were created and deleted.
- The free space on the disk fell from 92.1 GB (23:48) to 12.8 GB (02:58), and to 11.6 GB at 04:54.
- macOS's disk-writes report for 00:47–04:58: 549.76 GB written. Heaviest stack, 47,521 of 51,627 samples: Camera Raw's scratch thread →
PurgeTileData→WriteScratch→pwrite. Lightroom's footprint went from 21.8 to 46.1 GB (maximum 63.9 GB).
- Of the Lightroom 10.0 processes in our captures since Nov 14, 11 held more than one scratch file. The largest totals seen: 113.7, 73.1 (the first process above), 34.1, 30.0, 19.5 and 19.0 GB.
System Details
- Lightroom
10.0 MAS arm64 [ 20261029-1525-df1be3b ](Mac App Store) - Camera Raw
19.0 [ 2790 ](Help > System Info, "Internal Camera Raw version"), built into Lightroom - macOS 27.2.1 (26B131), MacBook Pro 16" (MacBookPro18,2), Apple M1 Max (10 cores), 64 GB RAM, 1 TB SSD
- Cameras: Canon EOS R5 Mark II, R6 Mark II and R6 Mark III (CR3)
