Click here to Skip to main content
14,775,019 members
Articles » Development Lifecycle » DevOps & Installation » General
Article
Posted 20 Dec 2020

Tagged as

Stats

6.9K views
12 bookmarked

Go Easy on your SSD/HD Drives, use RAM Disks instead for Testing

Rate me:
Please Sign up or sign in to vote.
4.78/5 (11 votes)
20 Dec 2020CPOL
Using a RAM disk instead of an SSD drive prevents an early death of the SSD and the tests run even faster.
SSD drives can support only a limited number of write cycles. During testing, data might get written repeatedly to a drive, but does not need to get saved long term. This stresses the SSD drive unnecessarily. Better use a RAM disk, which supports unlimited writes and benefit additionally from its higher speed.

Introduction

I got my new laptop, which has only SSD drives (solid-state drive). SSDs are faster than hard disks, but unfortunately, they don't really like being written to. When just one 1 bit needs to get set from 1 to 0, the poor SSD can't just do that. It has to take the block (typically between 256KB and 4MB), in which the bit to be overwritten resides, and copy the block with the changed bit(s) into an empty block, then has to erase the complete old block by applying a higher voltage. This stresses the SSD and SSDs support only a limited number of write cycles (typically between 3,000 and 100,000 writes).

Your unit tests are supposed to be run often. If possible, the test runs only using RAM. Unfortunately, this cannot always be achieved, especially when the test includes file processing or database access. In that case, it is better to use a RAM disk instead a SSD or HD drive.

A RAM disk behaves like a SSD or HD drive, but the data is only stored in RAM. RAM is much faster than SSD and it can be written to for a practically unlimited number of times. Unfortunately, Windows doesn't come with a RAM drive, but it is easy to install one.

Warning: Did ImDisk Make My PC Unstable ?

In the next chapter, I will recommend using ImDisk as RAM disk. However, few days after I published this article, my PC started to have strange errors, which may or may not be related to ImDisk. Since the Uninstall, I don't have errors again. That doesn't proof anything, but I thought I give a warning here. The unistall was easy. I would be curious to hear if others encountered problems as well. I guess sooner or later I give it a try again, but not right now.

RAM Disk Installation

A popular RAM disk toolkit is ImDisk. It uses the interesting WTFPL copyright: Do What the Fxxx You Want to Public License. Basically, it gives you the right to do anything with it. And it hasn't annoying advertisement.

I downloaded if from https://sourceforge.net/projects/imdisk-toolkit/. It comes in a zip file. Unzip and run install.bat. It runs an installer, which installs the driver and some utilities. I was just interested in the RAM disk and therefore started the RamDisk Configuration app.

Basic Setup

You can install several RAM disks with different drive letters. Launch at Windows Startup is very convenient, the RAM disk starts when Windows starts and is always available.

Advanced Settings

Windows creates with every start a new RAM disk. Like any other drive, before the RAM disk can be used, it must be formatted. Quick Format is good enough.

Data Settings

I didn't change anything here. However, if you would like that the RAM disk has already some content when it starts, like an empty database, you can use Load Content from Image File or Folder for that purpose.

Once you press OK, you are done and the new RAM disk is running. The only thing you need to do now is to change the SSD/HD drive in your test software to the RAM disk,

Points of Interest

I use the RAM disk not just for unit tests. In my final application, I give the user a test mode. There he gets a copy of the actual application data and can try out various functions, without changing the actual data. Also, this copy gets stored in the RAM disk.

Furthermore, I often work on files for only a short while, like taking the screen shots for this article, processing them and uploading them to CodeProject. Using the RAM disk this becomes extremely fast, and best of it is that I don't need to clean up these files when I no longer need them, the RAM disk automatically loses them with the next Window start.

History

  • 20th December, 2020: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Peter Huber SG
Software Developer (Senior)
Singapore Singapore
Retired SW Developer from Switzerland living in Singapore

Interested in WPF projects.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Michael Sydney Balloni21-Dec-20 10:51
professionalMichael Sydney Balloni21-Dec-20 10:51 
Very informative and easy to follow and compelling. My team will take this and run with it.
QuestionMessage Closed Pin
20-Dec-20 4:21
MemberUser 1106097920-Dec-20 4:21 
AnswerRe: No sorry ... Pin
Chris Maunder20-Dec-20 4:38
cofounderChris Maunder20-Dec-20 4:38 
GeneralRe: No sorry ... Pin
User 1106097920-Dec-20 4:42
MemberUser 1106097920-Dec-20 4:42 
GeneralRe: No sorry ... Pin
User 1106097920-Dec-20 5:03
MemberUser 1106097920-Dec-20 5:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.