How does Photoshop allow you to edit files larger than your device's memory?



Photoshop , an image editing software developed by Adobe, is widely used around the world to create and edit illustrations, posters, cartoons, etc. In such Photoshop, the size of the file being edited becomes very large, sometimes exceeding the memory (RAM) capacity that can be used by PCs and tablets. Adobe's principal researcher Nabeel Al-Shammer and others explain the question, 'How does Photoshop allow you to edit files that exceed the memory of your device?'

How Photoshop solved working with files larger than can fit into memory - Chrome Developers
https://developer.chrome.com/blog/how-photoshop-solved-working-with-files-larger-than-can-fit-into-memory/



Editing a file in Photoshop requires much more memory than simply opening a PSD file in Photoshop. Also, PSD files store data with lossless compression, and all image data is decompressed when the file is read, so the amount of memory required is several times that of storing files on HDD or cloud storage. It is said that there is a possibility of becoming.

What makes Photoshop's memory management even more difficult is that the file you're editing has a huge amount of undo history. When you perform operations such as 'brush fill' or 'erase unnecessary draft lines' in Photoshop, new pixel data is generated that is the same size as the original pixel data, and the longer the editing session, the more history data accumulates. I will continue. As a result, Alshamar points out that the editing history of a file can reach hundreds of MB to several GB.



Devices such as PCs and smartphones have different amounts of memory that can be used, and platforms such as browsers and apps manage the amount of memory used for work. Ideally, the app should be free to use as much memory as it needs, which will give the user the best possible experience, but if you use a lot of memory like Photoshop, the file size can easily hit the memory limit. It is said that it will exceed. Many platforms support virtual memory , which uses part of the hard disk like memory, allowing you to exceed the limits of physically available memory, but there are limits.

Therefore, Photoshop implements software called ' virtual memory system (VM: virtual memory system) ' to deal with the upper limit of memory capacity. The VM manages all 'undo' history and states, current working storage, and is also used to cache large blocks of data, such as brush descriptions.

Also, one of data management by VM is to store image data as mipmap . Mipmaps are precomputed and optimized sets of images of various sizes that complement the main texture image, providing low to high resolution image data. In Photoshop, when enlarging or reducing the image being edited, it is displayed quickly by using a prepared mipmap instead of processing the original image one by one.



Photoshop determines the amount of memory available during application initialization and also reserves for data stored in the VM. The VM's memory is divided into units called ' pages ', referring to square areas of pixels in a single layer as 'tiles'.

For disk-based mapping of VM pages, Photoshop creates one or more scratch files containing many VM pages. As the VM needs more mappings, it creates additional scratch files, and as pages are freed up, the space in the scratch file can be reclaimed for new pages, Alshammer explained.

When working with image data, Photoshop iterates over the tiles and performs pixel calculations. At this point, the VM ensures that the source and target tiles for iteration are in memory, reads from the scratch file as needed, and writes pages from the scratch file to make room in memory. That's what I'm talking about.

'The specific implementation details of the VM are far beyond the scope of this article, but I hope that by outlining the solution, you can understand how Photoshop handles large files,' Alshammer said. I intend to,' he said.

in Software, Posted by log1h_ik