Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A little ago, out of curiosity, I wrote a Java program that takes up a lot of memory very fast. (It adds BufferedImages to an arraylist in a loop.)

I kept the Windows System Monitor open to observe the RAM usage as it ran.

When I started the program, the RAM usage climbed really fast, and as it reached about 100% of my 6GB of RAM, my computer became extremely slow. After about one minute, I managed to terminate the program and my computer slowly recovered speed. What caught my attention was that the memory usage first dropped slowly, then suddenly it went right down to almost 0MB before climbing back up to to idle usage at around 2-2.5GB.

I took a screenshot of the RAM usage in the System Monitor:

enter image description here

I was wondering if anyone could explain what happens as the computer runs out of memory and why it doesn’t go back to idle right after the program ends but rather about 60 seconds later? Also, why does the usage go all the way down to nothing instead of just idle usage?

share|improve this question

migrated from Jun 24 '12 at 15:31

This question came from our site for professional and enthusiast programmers.

This does. – Alex Lockwood Jun 24 '12 at 15:30
That’s not 0MB (or even close to it). Assuming you took a screenshot of the whole graph, then the lowest point is 814MB; even more if you cropped it. – Synetech Jun 26 '12 at 4:36

When you start reaching the limit of main memory your operating system will start to swap out memory to disk to make room for more stuff (this is called paging). This is why your computer is getting really slow because the disk drive is waaaay slower than RAM, even if you're on a SSD, and it's also the reason your program can go on without any main memory left.

Idle memory is often swapped out first so that active programs can have as much as possible in RAM. This is the reason memory usage goes down below the usual idle state. The system will start to swap in memory pages again and the idle memory will fill up in RAM eventually.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .