In This Article
What is Disk Thrashing?
Disk thrashing, virtual memory thrashing, or simply thrashing refers to the state when the hard disk overworks to move data to and from the system and virtual memory excessively, barring most processing at application level.
Technically, thrashing is caused when the virtual memory is used to exchange data from a hard disk as the main memory gets full. Added pages are exchanged in and out of the virtual memory causing a very high rate of hard disk access.
Disk thrashing is a phenomenon that happens when there is insufficient memory and resources in the system, too many files are running at the same time, and the system swap file is not configured properly.
Disk thrashing reduces the performance and may also result in serious consequences since the hard drive has to work constantly due to the huge amount of work it has to do.
Such an incident may not be a serious concern if it happens for a short time but prolonged trashing, if not taken care of, may result in early hard drive failure, data loss, and permanent damage.
When trashing happens, the hard drive is taken hostage by a background process so that it finds it hard to keep up with the high read and write rates and responds very slowly due to the processes overloading its physical limitations.
Disk thrashing, in simple terms, is the state when the operating system uses the disk for memory due to excessive and more frequent reading or writing operations. Providing more RAM often resolves this issue.
Understanding Disk Thrashing
When the computer system starts using the virtual memory too often and too much, it results in being accessed more for swapping pages. This results in disk thrashing.
This specific phenomenon slows down the computer considerably because the data needs to be moved back and forth less efficiently to the physical memory from the hard drive.
In such situations, the application may stop responding but that does not keep the disk drive’s light from blinking on and off.
This is because too many applications or programs need to compete for memory access.
However, the possibility of it happening and failing is greater in the case of HDDs than SSDs due to the mechanical disks in them and the moving head hovering over the disk in order to read from and write to it.
In comparison, on a modern SSD, the individual cells usually come with a higher lifespan, but can still be reduced if you write and delete data constantly to and from them.
In contemporary computers, disk thrashing may happen in two specific situations such as:
It may happen in the paging system when the access time to the disk is exceptionally long or the physical memory is insufficient.
It may also happen in the I/O transportations subsystem, especially when there are conflicts while accessing the internal bus.
Disk thrashing may have little impact initially, but if it is allowed to continue, it may cause serious issues.
It will slow down the computer and reduce the performance level due to the physical limitations of the Hard Disk Drives.
In spite of its limitations, it will have a lot of work to do as programs and applications continue loading.
Prolonged thrashing also results in a significant rise in the temperature level.
Therefore, intense disk thrashing will result in a permanent hard drive failure.
What are the Causes of Disk Thrashing?
The primary reason behind disk thrashing is excessive usage of the resources of the virtual memory by the computer due to insufficient system resources and memory, or because the main system memory is full.
This typically results in continuous page faults or a state of swapping pages inhibiting application-level processing.
Typically, the common causes of disk thrashing can be summarized as follows:
The computer system does not have enough memory or resources.
The system encounters a memory leak issue.
There is an improper configuration of the system swap file.
Improper and higher priorities of a few applications than others.
Too many files are running in the background at the same time.
In such conditions, the additional pages are swapped in and out of the virtual memory at a rapid pace which increases the access rate on the hard drives.
Here are some other significant causes:
Ideally, the pages that are accessed more frequently are called the working set, which may also cause disk thrashing.
When there are too many computer processes, they have to compete for the available and inadequate memory resources and lower CPU utilization.
Ideally, after initialization is complete, most of the programs run on a small number of data pages and codes in comparison to the total amount of memory needed.
This is where the concept of a working set comes in, which may also result in disk thrashing.
When this working set is a small percentage of the total number of pages in the system, the virtual memory systems work very efficiently.
In these situations, a small amount of computing is expended in order to resolve the page faults.
When this percentage of working sets increases, things are still manageable in terms of resolving page faults, but only up to a certain point.
When this reaches a critical point, the faults also increase significantly along with it.
During these times, the time required to resolve the faults is much more. This results in disk thrashing.
This happens especially when the program typically has to work on large data structures.
This increases the working set resulting in continuous page faults and disk thrashing that slows down the computer system.
When the use of virtual memory is frequent and high, it may lead to unproductive CPU utilization, which may bring the computer system to a grinding halt due to disk thrashing.
Ideally, the virtual memory treats a part of the secondary storage, such as a computer hard disk, as an added layer of the cache subsystem while operating.
The virtual memory is known for permitting processes and applications to utilize more memory than what is present physically in the main memory. Apart from that, it is also known for permitting virtual machines.
The operating system, on the other hand, assigns a virtual address space to the processes while supporting the virtual memory.
This purported virtual address is referred to by every process as an address while execution.
When the process needs to access a specific type of data such as variables or codes at that specific virtual address, it needs to translate it to a physical address. This is done by a process called virtual address translation.
However, in reality, the physical memory of the main system becomes the cache memory for the virtual memory. This is generally stored in the memory pages on the disk.
The programs are assigned a specific number of pages based on the requirements of the operating system. These are called active memory pages and are found both on the hard disk and in the RAM.
The inactive pages, on the other hand, are removed from the cache memory when the main memory gets filled up and are written to the disk.
When the process uses the whole main memory and needs more memory pages, a series of significant cache misses will happen.
These are referred to as page faults that result in a severe lag in the performance of the operating system and reduce its responsiveness.
When this process continues to happen alongside repetitive yet futile page swapping, disk thrashing sets in.
Ideally, disk thrashing may occur when the CPU performs less productive work and more swapping.
It mainly depends on the algorithms involved and the configuration, which affect the latency and throughput of the computer system.
This typically happens due to the degrading in the multiple orders of magnitude.
This increases the general memory access time mainly because the higher-level memory in the memory subsystem is only as fast as the subsequent lower level in the hierarchy.
This keeps the Central Processing Unit (CPU) of the computer system busy swapping pages.
This means that the CPU cannot respond to the interrupts and the user programs as much and as fast as required.
When there are too many pages existing in the memory, thrashing sets in, where every page has to refer to another page, slowing down the system eventually.
In such a state, the capacity of the main or real memory gets reduced, so much that it cannot accommodate all of the pages in it.
This leaves no other option but to use the virtual memory.
When every page in implementation demands a page which is not available currently in the real system memory, the CPU will place some of these pages on the virtual memory. the required page will be adjusted on the RAM.
When the CPU is engaged in this particular task more, its utilization is not as desired, and it results in thrashing.
How Do You Stop Thrashing?
The most effective and common way to stop disk thrashing and its effects is to allocate as many frames as required by each process during its operation.
You can find out the number of frames needed by using the locality model, which typically refers to the set of pages that are being actively used together.
A few other effective ways to eliminate or prevent disk thrashing and its negative impact on the hard drive as well as the overall performance of the computer system are as follows:
Add more Random Access Memory (RAM) to your computer because an insufficient amount of RAM does not allow it to handle tasks easily and results in its working excessively.
Shut down a few applications that may be running in the background but are not needed currently. This will free up some system resources. Too many applications will consume too much resources of the computer, often unnecessarily, and also slow down the remaining resources causing disk thrashing.
Modify the swap file size and configure it correctly. This will also reduce disk thrashing by a significant margin.
Disable Windows telemetry which collects data about disk usage and causes privacy issues. Disabling this service will give some rest to the hard drive.
Disable or rebuild Windows search indexing, which slows down the drive, to release stress on the hard drive.
Disable the SuperFetch utility running in the background to stop writing to the drive and save some valuable system resources.
Disable the integrated Windows Tips app running in the background to improve the performance of the drive as well as the system as a whole.
If you run Skype, give it the permission to write data to one of its subfolders rather than your hard drive and ramp it up.
Disable prefetch in Chrome to reduce the additional load on the hard drive and the computer system and to keep track of the sites you are most likely to visit and preload the pages in the background.
Fix the Advanced Host Controller Interface or AHCI driver to prevent bugs affecting your computer system and 100% usage of your hard drive.
Disable automatic Windows Updates that may happen automatically at random times so that you prevent maxing out your hard drive.
Scan for malware and viruses in your system by running a full system scan with a good antivirus software program and then remove them.
Update your operating system as well as the antivirus program so that you get the latest bug fixes as well as plug in all the security holes.
Reinstall or reset synchronization tools such as Dropbox and OneDrive if they are stuck or take a long time to synchronize the files. In these situations, these tools will use a huge amount of data.
Make sure that your hard disk is free from any physical defects, and if there are any, have them repaired immediately to prevent 100% disk usage.
Delete all page files that are malfunctioning since these are used as expanded memory by the computer system when it runs out of free RAM and causes disk thrashing.
Delete all temporary files not only to free up disk space but also to prevent the potential bugs in them from affecting the system performance by causing an application or Windows process to create hundreds or thousands of files, thereby propelling disk thrashing.
Update all the drivers of your computer hardware, especially the hard disk controller apart from the hard drive itself. This will ensure that there is no bug in the outdated driver that may push disk usage to 100%. Also update the hard drive software, known as firmware.
Now, here are some of the things that you should certainly NOT DO in anticipation of fixing hard disk thrashing.
Do not disable antivirus (update it instead, as said earlier).
Do not turn off disk defragmentation.
These are not only unhelpful but are also very dangerous for the hard drive as well as the computer system as a whole.
How Do You Detect Thrashing?
Since trashing is the result of the under apportionment of the lowest number of pages needed by a process that forces a continuous page fault, it can be detected easily by assessing the level of utilization of the Central Processing Unit and comparing it with the level of multiprogramming.
Ideally, there are two specific methods to detect disk thrashing.
Click on the Start Button
Type in perfmon.exe /res
(This will open the Resource Monitor on Windows 7 and Windows Vista)
Once it opens, look at the overview screen
Click on the disk section
Click on the down arrow
Look at all the files and processes on the drives that are read or written
Sort all disk operations by clicking on the Read, Write or Total headings
Now, identify the particular process or file that is using the disk most.
Alternatively, you can visit the Sysinternals web site of Microsoft and download the Process Explorer from there. Once the download is complete and the tool starts running, follow these steps:
Click on the View menu bar
Click on the Process I/O tab
Check Reads and Read Bytes
Check Writes and Write Bytes
Click on OK
This will display the new columns for each listed process. Look for the specific process from the list that has the highest number of reads or read bytes. This is the process that may be killing your hard drive.
Once you have identified disk thrashing and the bad processes, you can then rectify it by using the Task Manager.
You can also detect disk thrashing in the following ways:
Open a folder containing videos or photos. If the preview thumbnails take a lot of time to load or the green bar fills up the top of Windows Explorer very slowly, there is an issue.
While gaming, if the game takes a longer time to load than usual, coupled with stuttering, or the game stops erratically for a couple of seconds, it indicates that the disk cannot keep up and is ‘thrashing.’
Stream content on the audio or video player. If you see that it is buffering constantly, displaying blurry images, playback is interrupted, or anything that is disrupting the online stream, it indicates disk thrashing.
When you hear distinct and audible noises of rattling from the hard disk when it is busy, it clearly indicates disk thrashing happening inside.
In short, general sluggishness and unusual lags of the computer while opening any item, application or menu indicates disk thrashing or high disk usage.
Typically, use your Task Manager and watch out for any process or file that takes an extended period of time to open, irrespective of its size.
All these are worth worrying, regardless of the impact on the performance it may have.
So, as this article has pointed out, disk thrashing can become a serious issue soon if you do not take care of it.
It will initially slow down your computer, and gradually may result in considerable wear and tear of the read/write heads while transferring data back and forth, resulting in a permanent failure of the hard disk.