The major and the basic function of computer memory is to store all the data on the computer. Depending on the type of data, apart from storing data, it performs some other functions as well. All its functions are related to storage only due to its primary role of storing, like RAM, ROM, data storage, hard drives and flash memory. Each of them performs its required function to keep the computer working.
The functions are as below.
Random access memory (RAM) provides the space for all the temporary application data storage. Whenever a computer needs some data, instead of going back and finding information on the hard drive, it gets it all in the RAM as it stores all the frequently used applications. This becomes easy for the system to find the required information.
When we shut down the computer, the system erases or transfers all the data of the RAM to the hard drive while making a room for the new data to get stored when the computer begins its operations again.
— Hard Drive
A hard drive is the core of a computer's data storage. It supplies storage for system and user files that include everything from your operating system to images and documents. In technical terms, a hard drive is a rotating disk that is treated with a magnetic coating, similar to the magnetic ribbons, which are used to store data on cassettes. There is one moving arm that reads and copies all the data and from the rotating disk, it allows you to save the new data or open files from the hard disk.
— Flash Memory
Flash memory is the common term used for electronically-erasable-programmable-read-only-memory (EEPROM). This is used in video game cards of the computer and also to store some important information of the system. It is not like the other memory types that erases or copies data byte-by-byte rather EEPROM is used to edit data in groups of bytes while making it an easy and a convenient choice for the devices like memory sticks and cameras where the data stored changes frequently from time-to-time.
Read Only Memory is termed as ROM. The data that is stored by ROM is used to control the most basic computer functionalities, such as starting up, operating the computer fan and detecting peripherals. And, as the name suggests, the system or the users cannot edit this data. Everything recorded stays over there even after switching off the computer. Similar to the flash memory and hard drives, ROM is an example of non-volatile memory. Being non-volatile means that the data stays in place even when the power is off.