Hotspot vs. virtual memory

Dear Lazyweb. It seems to me that (on the Hotspot VM) the Java heap is always kept in RAM and never swapped out, because the GC is continually accessing the memory. For example, if I have Firefox, Evolution and Eclipse running, and then start a compilation that takes a lot of memory, Firefox and Evolution get swapped out, while Eclipse (which takes up around 1G on my machine) stays in memory all the time, thus effectively stealing memory from the compilation process. Has anybody else observed this too? Is my diagnosis correct? Is there a way to fix this? Would be nice if Java programs behave similar to other programs and don’t lead the virtual memory system ad absurdum.

Advertisements

3 Responses to Hotspot vs. virtual memory

  1. Pingback: Hotspot vs. virtual memory

  2. Eclipse does that intentionally. The alternative tends to be much worse. Because in the Java VM (and all GC’ed managed languages that I’ve seen) the GC will tend to crawl a large area of the used memory every time it runs. If this memory happens to be RAM that is swapped to disk, then you get mad swapping, and likely a complete app freeze while it works.

    Eclipse used to be famous for this, as you’d switch to Firefox for a minute or two, then when you switched back to Eclipse you’d get the “white menu bar of doom” while it swapped everything back into memory for a GC sweep.

    There are some workarounds, but they all basically involve the symptom that you describe, as they just heavily discourage the OS from swapping out your block of RAM. I believe that Eclipse started using these workarounds on windows a couple of releases ago.

    In general, VMs and Swap interact very badly, and this is just a sympton of that.

  3. roman says:

    Check out this blog entry, it was interesting:
    http://blogs.sun.com/jonthecollector/entry/our_collectors

    I (Stølsvik) made some comments that got replied to, you might find
    some of that interesting.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: