Management of Photoshop scratch/temp files

Can someone (preferably from Abode) confirm or deny the information that I am receiving from AI regarding the management of scratch memory.

The context is that I currently have a prototype Photoshop Plugin which, each time that it runs, reduces the free memory on disc by 1 GB or more each time. The memory is only released when I close Photoshop. I am fairly sure that this does not arise because of a code error on my part. I have thoroughly reviewed and revised my code and so has more than one AI tool.

The observed behaviour seems consistent with the advice that I am getting from ChatGTP. – “Users often see scratch/temp space not returned until a purge or Photoshop restart”.

I tried an experiment to see whether my memory loss was due to stored history by including a ‘purge all’ at the conclusion of processing. It had no effect. ChatGTP has advised me thus. –

“purge → All doesn’t work in UXP because Photoshop does not allow batchPlay-triggered Purge commands to clear the History store.

Inside UXP, the History system is protected when:

the plugin is still running, a modal execution block is active, or a panel callback has not fully returned to Photoshop.

Therefore, Photoshop silently limits the purge, even though the batchPlay call reports success.”

ChatGTP states that to purge history I must either create a duplicate document and close the original or implement purge using a menu command triggered after plugin closes.

Returning to my original issue of memory loss, ChatGTP advises me that

“Your plugin is not leaking memory.

What you are seeing is:

Photoshop creating temporary scratch files on C:

for duplicated documents, for intermediate layer bitmaps, for Undo states, for History snapshots, for Smart Object caching, for document preview tiles, for expensive filters (especially batchPlay operations inside )

They are not freed until:

the document closes, Photoshop completes its idle cleanup cycle,Photoshop is fully idle (no modal execution), and History is cleared,

Because your plugin does not purge history, Photoshop cannot reclaim many of these scratch blocks.

This perfectly matches your observations.”

ChatGTP also advises me that ,Purge “imageCaches” is “a legacy CEP/Scripting instruction. Photoshop’s internal code removed this instruction around PS 2022. Also, Photoshop does NOT guarantee that purge(“undo”) works”

“There is no purge operation in modern PS that clears image caches except:

close document, close duplicated working doc, write new history state (sometimes releases tiles)”

Can anyone please confirm the following advice from ChatGTP for the management of memory arising from scratch/temp files.

(I don’t really wish to rework my code until I am confident that it will be worthwhile.)

“Use a separate temporary document and never modify the user’s working document directly.

Workflow:

Duplicate original doc

Run entire plugin processing on the duplicate

Copy the final layer back

Close duplicate doc → frees ALL of its scratch and temp history

User’s original doc retains full undo history

This avoids:

large scratch buildup, history conflicts and user data loss

And it is the method used internally by several Adobe plugins.”

1 Like

Don’t trust ChatGTP in this topic.

Photoshop often allocates more memory than it needs. Once it has it it might not be willing to release it… but rather keep it allocated for future operations. Or at least some of it. If it allocates more than it needs it will ensure that it can be more performant in some intensive tasks because it does not need to spend time figuring out how to allocate more. Purge can help.

1 Like

ChatGTP may or may not be trustworthy in this case, hence my question.

Clearly, Photoshop is unwilling to release memory, but there is no evidence that it keeps it allocated for future operations. It repeatedly increases the memory each time that I run the plugin which suggests that on a later run it is not using memory that that it had reserved on earlier runs.

Purge does not appear to have any effect for me. My experience aligns with that described by ChatGTP. I am pretty sure that it is correct on this specific issue but I would still like official confirmation from Adobe.

Please can someone from Adobe respond to my opening post.