Home » Questions » Computers [ Ask a new question ]

What is the relationship between CPU usage and RAM?

What is the relationship between CPU usage and RAM?

I have seen many times that the CPU usage is 100% and only 50% of the RAM is in use. What is the relationship between these two? How does one's performance affect the other?

Asked by: Guest | Views: 399
Total answers/comments: 3
Guest [Entry]

"The CPU processes (performs instructions on things, such as adding) stuff in memory. RAM is just part of the memory pyramid (see below). So when you are processing lots of data, that data ( or maybe large portions of it) will likely get loaded into RAM so it is ready for the cpu, this is to speed things up because RAM is faster to access than storage devices. So CPU usage and RAM can often correlate, but don't have to.

A basic example might be an image editing program. I load up my 20MB jpeg, the program reads the entire image, and the OS keeps that in RAM for you (all working memory looks the same to the program, the OS decides if it goes to the page/swap file on disk or RAM). So the image is in RAM waiting to be processed, but I go for coffee before telling the program to apply some silly filter, so the CPU isn't doing anything: high RAM low CPU.

I come back, apply the filter to add some bubbles to the image, and the CPU goes to 100% and even more memory gets used because it keeps the preprocessed image in memory, so I can undo the change I just made. High RAM, high CPU.

When the program is done adding the bubbles, the CPU drops, but maybe not the memory.

Of course, it isn't quite this simple :-)"
Guest [Entry]

"RAM is used to save data. CPU time is used to process data.

There is no relationship between CPU and memory usage. A process can occupy all CPUs of a system but use only a minimal amount of memory. Also, a process can allocate all memory available on a system but only use minimal CPU time. So there is no relation between both."
Guest [Entry]

"No relationship. Think of it in terms of doing some heavy-duty number-crunching. RAM is how many of those numbers can be stored for faster retrieval, whereas CPU is how fast those numbers can have mathematical operations performed on them.

For how one affects the other, let's assume that you have a slow CPU but lots of RAM. That means that you can store quite a few of those numbers in memory - about half a billion of them on a typical 32 bit machine. But processing/computation/etc on those numbers will be slower.

On the other hand if you have a fast CPU but a small amount of RAM, processing of the numbers will be fast, but from time to time the machine will need to drag them from disk (and put them back again to make room for more), which is many times slower than taking them from RAM.

So really, each affects the other, and for best performance you need both to be good. However, this totally depends on what each application is actually doing, and there are other factors (such as disk speed, processor caches, etc) which we needn't go into too much detail about for now, but which you should be aware will complicate things."