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.â