In This Article
What is Scratch Space?
Technically, scratch space is a specific volume that can be set occasionally when needed and is used commonly as an overflow when there is insufficient Random Access Memory (RAM) on the computer.
- Scratch space is the specific space on the hard disk drive used to store user data temporarily. It can be set and the data stored in it can be erased dynamically or periodically as well to have ample free space for future use.
- Occurring when required, this specific space typically needs dynamic management and is quite unreliable since it has no backup. However, it is much faster than a few specific file systems such as network file systems.
- Adequate scratch space can be created by setting up an empty partition on the primary hard drive or any other drive to be used typically for specific programs like Photoshop and by the scientific computing workstations.
- Scratch space can be used in different modes, such as signature and application modes, and typically consists of 256 scratch slots. Each of these slots can store a single integer or byte slice.
- A scratch space more or less functions just like the RAM of a computer and even offers similar benefits to its users. However, the difference between them is that the data is chosen manually from the scratch space.
Understanding Scratch Space
Many a time, while performing any computing task, a large number of temporary files may be generated while running a specific program than what is assigned in the research group storage or home directory quota.
These files and data are however not required in the long run and therefore are not necessary to retain them. These files can be deleted after the job is completed.
The scratch space is therefore created to hold these files temporarily while the program is running and then to delete them once it is done.
Scratch space is certainly not ‘scratched’ in the true sense and does not signify a bad sector on the hard disk either.
On the contrary to the term ‘scratch,’ in general, a scratch space signifies the temporary space in the computer memory that can be used to store data and information.
The scratch space is best located on the drive rather than on the main drive of the computer. There are two specific reasons to say so, which are:
- The scratch space can conveniently provide adequate and additional storage space even when new files and programs are added.
- Since it is on the hard drive, it does not have to depend on the power to maintain the data stored on it, as opposed to the main memory of the system.
However, on several systems, the scratch space may be located on the same hard drive as the other programs and the operating system by default.
This may create some significant issues when you need to download additional software programs and files for the operating system such as:
- The hard drive will fill up in no time, thereby leaving no room on the disk to create scratch spaces.
- It may also not allow the computer system to use the scratch space as appropriately as it should, because there will be other data stored there as well.
Therefore, it is best to have the scratch space on a different drive or on a specific area on the disk that is specifically partitioned for creating a scratch space.
It is good to have more than one dedicated drive for use as scratch space. This will be much more efficient than having a single drive dedicated for this purpose.
However, if you have only one drive on your computer, you may increase its efficiency by creating a separate partition on it that will not be used for or by anything else.
This will ensure that there is some space always available to be used as scratch space.
Ideally, this specific space is created and used under specific conditions, such as:
- When another memory location is full
- When the other memory is slower
- When the other memory is offline
With reference to the hard disk, a scratch space is the same thing and is created and used for the same purpose of storing data temporarily when the RAM is full. Such situations may arise when you use highly intensive computational applications such as:
- Editing a video file
- Editing large images
The required data for such operations will be stored in the scratch space.
Ideally, for programs like Photoshop, the minimum free scratch space required is 6 GB. However, the available free scratch space considered by the program is the remaining current free space on the hard disk.
This means that, if the free space on the scratch disk is 10 GB, Photoshop will consider the available space to be 10 – 6 = 4 GB. This may or may not be enough for the current operation being executed.
Therefore, even if you make some minute changes, you will need at least 10 GB of free space for Photoshop along with its defaults, such as
On the other hand, you will need much more than that, in fact, as many times the size of the actual file as the history states, if you make significant changes to the dense pixel layers such as:
- Using many edits to a big smart object
- Using many filters on intricate background images
Therefore, it is recommended that you have at least 20 GB of free space on your hard drive with the operating system when you work with Adobe Photoshop.
Yes, you may also need much more than that at times, but that will typically depend on the particular type of file you are working with.
There are few specific protocols or etiquettes for a scratch space such as:
- These spaces are intended to be used as a temporary storage to read and write data for the current job.
- The data stored in these scratch spaces, if required, to a permanent location or delete them if not needed in the future.
- These spaces are typically a shared resource and therefore should be freed periodically.
- Being temporary in nature, these specific spaces do not persist over and above the recent transaction.
- You can use the scratch space in both signature and application mode.
- There may be as many as 256 slots in a scratch space for storing a byte or an integer.
Reading and Writing
Using ScratchVar is the best possible way to read from and write to a scratch space. For this, you will need to create a ScratchVar object first and then enter the values that you want to be stored there.
However, you will need to keep a couple of things in mind, such as:
- You may create a ScratchVar to store both byte slices and integers by not passing any arguments to the constructor, but you must make sure that in such situations no type checking occurs.
- You may also specify the particular slot ID manually to assign the scratch slot to a code. If nothing as such is assigned, then the compiler will allot it to any slot that is available.
- In order to read and write values, the corresponding ScratchVar.load or ScratchVar.store methods should be used. And you should invoke ScratchVar.store before you invoke ScratchVar.load.
- One of the 256 scratch slots is assigned automatically to every variable while working with a scratch space while using the ScratchVar class.
How to Check the Scratch Space?
You can check the scratch space on the disk on your computer by using different command lines based on the operating system and the settings and by accessing the directory or the File Manager, as the case may be.
On a local machine, you can access the scratch space by changing the directory to /local/scratch/public and by making a directory for yourself.
As the directory name, you may use your login name, as most people do, and check the scratch space from there.
You can also access and check the scratch space over the network in two specific ways, such as:
- You may log into the system with the data space to create your directory by changing directory to /local/data/public.
- You may simply change the directory to /data/machine_name and then create the data directory.
If you are using XUbuntu, you can check the scratch space by:
- Opening the File Manager by clicking on the File System icon on your desktop
- Looking at the text in the Location text area
- Replacing it with a complete path to the space you want to access
- Pressing Return
- Creating a new folder
- Naming it after your login name
- Placing all your files in there
In some cases, you may even check the scratch space volume storage quota and its usage by using the $ gpfs_quota scratch command.
How to Fix a Scratch Space?
In order to fix scratch space and prevent it from becoming full often, do not wait till you get the error message.
Instead, free up the space by deleting unnecessary files or by moving the files from there to another storage location. You can clean it dynamically or periodically.
There are several ways in which you can do it manually. Choose one or more of the following options.
Clear Photoshop cache
This is the easiest way to fix scratch space and make it work properly. Here’s how:
- Open the Edit menu in Photoshop
- Click on Purge
- Select all or a particular cache to clear such as video cache, clipboard, or histories
Clear temporary files
Here’s how you can remove the temp files in Photoshop:
- Save and exit all programs
- Press the Windows key and the R key at the same time to open the Run box
- Type %temp%
- Hit Enter
- Select the files named Photoshop or PST
- Click on Delete
- Close the temp folder
- Open Recycle Bin on the Desktop
- Select Empty Recycle Bin
On Mac computers, you can use Spotlight to look for temporary files and delete them.
Change scratch disk on startup
If there are multiple scratch disks, switch between them on startup. Here’s how to do it:
- Launch Photoshop
- Press and hold down the Ctrl and Alt keys (on Windows) or the Command and Option keys (on Mac) at the same time
- Choose a new scratch disk from the Startup dropdown menu
- Click OK
Change drives or partitions
Photoshop, by default, uses the drive of the operating system only for scratch space. If you have multiple partitions or drives, let it use them. Here’s how:
- Launch Photoshop
- Click on the menu at the top
- Select Preferences
- Choose Performance
- Go to Scratch Disk section
- Enable and disable scratch disks
Disable the auto recovery feature
Photoshop will save the files being worked on automatically for auto recovery. If that is not needed, you may disable it. Here’s how:
- Launch Photoshop
- Click on the menu at the top
- Choose Preferences
- Select File Handling
- Uncheck the Automatically Save Recovery Information Every box
You may let Photoshop use more RAM to reduce scratch disk issues. Here’s how:
- Open the Photoshop menu
- Select Preferences
- Choose Performance
- Select Let Photoshop Use box on the right-hand side pane
- Enter the amount of RAM you want Photoshop to use
- Click on OK
Reset crop tool value
Crop large images to save space by following these steps:
- Open Photoshop
- Go to Crop Tool
- Remove the values from the boxes
- Enter new values with pixels as the unit
Defrag the hard drive
You can defrag the hard drive of your computer in the following way:
- Go to the Start menu
- Look for Defragment
- Click on it
- Choose Optimize Drives
- Select the drive partition that is used as a scratch disk
- Click on the Optimize button
Reset Photoshop preferences
If too many changes are made to Photoshop preferences, it may create some issues. Reset it in the following ways to fix it:
- Quit Photoshop
- Press and hold down the Shift + Ctrl + Alt keys (on Windows) or Shift + Command + Option keys (on Mac) to launch Photoshop
- Click on Yes on the prompt to delete the Photoshop settings file.
Is Scratch Space Same as RAM?
Yes, you can think of the scratch space as an extension of the Random Access Memory of your computer because both store the data of the programs that you are working on currently, and both offer temporary storage.
Though it does not work exactly like the RAM, it often offers similar benefits to the computer users.
However, the most significant difference between the two is that the data stored on the scratch space is usually chosen manually.
Typically, breaking down a considerable portion of the hard drive with the boot file and leaving that space empty warrants a more reliable scratch space.
Usually, partitioning a hard disk drive based on each gigabyte is cheaper than RAM.
And it also frees up the RAM to focus on other tasks while it will store the required data required for the current program.
However, it may perform at a much slower rate than RAM.
Normally, a scratch space may not match the speed of the RAM, but it can be improved a bit by assigning a separate physical drive from the primary software and operating system.
A scratch space, as you know now, is a specific location on the hard drive disk where you can store program files and projects temporarily while using programs like Photoshop and access them while it is running.
It is easy to check whether or not it is full and also clean up often to prevent issues and make it work properly.