Windows Swapping out Java

I’ve noticed that windows does an annoying thing to java apps. At least thats my perspective.

If you run something like eclipse and are using it, you can check the process manager. It will probably show at least 20Meg or so.

If you minimize eclipse or any java apps, the memory drops down after awhile. My assumption is that much of the app is getting swapped out to the hard drive.

When you then go to use the app and maximize it again, you can watch the memory footprint jump as it puts everything back into memory. This ends up taking about 30 seconds or so, before the once responsive java app becomes usuable again.

Linux doesn’t appear to suffer from this. Nor do executables that are binaries.

Is there some way to make windows stop this? What about some command line args for the jvm?

seen that before…

me too. If I have Eclipse running, and leave my computer for a couple hours and come back and pull back up the window, it takes a long time for it to be usable. My computer clicks like mad for like 5 straight minutes doing seemingly nothing until I can finally type some characters into Eclipse. Then after a minute it’ll start all over again taking another 5 minutes to give me back control of my keyboard. Then usually after that it’s ready to be used again.

[quote]me too. If I have Eclipse running, and leave my computer for a couple hours and come back and pull back up the window, it takes a long time for it to be usable. My computer clicks like mad for like 5 straight minutes doing seemingly nothing until I can finally type some characters into Eclipse. Then after a minute it’ll start all over again taking another 5 minutes to give me back control of my keyboard. Then usually after that it’s ready to be used again.
[/quote]
The reason this happens is described here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;293215

This is true for all apps, not just Java ones

I don’t think its completely true for all apps. Netscape crawls like a pig when you come back and maximize it. Explorer, interestingly, doesn’t seem to.

One trick, which is already been round about mentioned is to simply not minimize your apps. It gets annoying trying to move around a bit, but otherwise works.

I’ve often wondered about virtual memory in modern computers, especially windows. When I was married to my Amiga, it never had a virtual memory. What you physically had is what you used. I still haven’t ever figured out the REAL benefit of virtual memory. If I have a Gig of ram and thats not enough to keep everything in memory, then something seems out of whack. And why in heck do I need a default swap size thats just as large as my physical ram? Its looks like something just asking for problems.

Any idea on how to mess with the windows settings to optimize things better?

Herkules, thanks for the reference. I had missed that one!

Virtual memory is an anachronism. Once upon a time RAM was rare and expensive. Now it’s so cheap I can have a gig in a laptop, which is twice the size of the physical RAM plus the swap file on my last desktop.

So: ajiva, is there a possibility you might be able to add some flags to the VM so that we can pin a certain amount in the working set rather than let Windows swap it out?

Cas :slight_smile:

[quote]I don’t think its completely true for all apps. Netscape crawls like a pig when you come back and maximize it. Explorer, interestingly, doesn’t seem to.
[/quote]
…it’s explained in the KB article.

re: virtual RAM, I’m firmly with Cas. I’ve disabled VM on windows since 1999. Unfortunately, some windows apps are **** stupidly coded to REQUIRE VM, including Unreal Tournament (sob) and will simply crash (pseudo-randomly) if they can’t find enough. Great.

Also, lots of crap DX games (and some flash stuff IIRC) crashes when windows automatically increases the swap space (despite you not needing it to nor wanting it to) and pops up a dialog to tell you. IIRC this is simply because the programmers were too lazy or ignorant to code the handlers for losing the accelerated RAM and needing to repopulate. If you live in the UK then Golden Grahams had a promo giving away CD’s with an Umbo-sponsored football game that has this problem. But then it also has a spectacular memory leak, so I don’t think much of the muppets who wrote it and claim to be a pro studio :slight_smile: (yours truly had to support a family member trying to run it and discovered this calamity of incompetence :().

What I meant by not all apps doing it, is that MS is pig and they probably have theirs coded so that it won’t swap out. They use the workaround in the article you see. :wink:

Anyway, I just disabled all my VM and voila! I have a brand new machine. I doubt that we can convince the users of our programs to always do the same, but its worth a try.

Now I just need to do this on my machine at home.

I feel like its christmas. :slight_smile:

A better approach would be to use the alternative minimise mechanism which doesn’t trim the working set; possibly selected by a command line switch. Also the garbage collector could request an increase in working set size before doing a full collection.

[quote]Also, lots of crap DX games
[/quote]
Sod crap games, the majority of DX games I’ve played seem to suffer from this, regardless of how good they actually are. The ones that don’t have other weirdness going on that plays havok when you alt-tab or switch away in some form.

It does seem to have gotten better in the last year or so though, but I still cringe when I have to minimise any fullscreen game, knowing full well that the odds aren’t in my favour…

Hm, actually now that you mention it, I suddenly realise you are quite right about DX based games. I’ve just gone and tried a few and they all exhibit awful, awful behaviour with alt-tab.

Cas :slight_smile:

Heh, this is where OpenGL really shines: The designers knew that a condition occurring very rare (loosing buffers) should be avoided at all costs. So OpenGL preserves textures and other resources created by the application. The only exception (that I know of is) is memory mapped VBOs.

  • elias

It is very easy to modify SWT of Eclipse and see if it works… You only need to touch one file: org/eclipse/swt/widgets/Decorations.java and add 5 lines of code. No JNI required. If anyone is interested I can email the modified \eclipse\plugins\org.eclipse.swt.win32_3.0.0\ws\swt.jar file. If only I didn’t have 2gigs of RAM at work…

To the swap file disablers. Congratulations on this approach, it’s really bright. O_O
My current swap file is filled to 221 MB. My memory is 128+64 MB. Now lets consider hypothetical situation, what would happen if I didn’t have any swap file.

Cas it was very funny. This also means that you’d be unable to run my current game, nor to run my original tester (I trimmed it down a little because it throwed an out of memory error when tested on a computer with disabled swap file.).

My current specs are: 196 MB RAM 133. 1.4 GB swap on separate logical drive, non fragmented, and with unchanging size. (Processor scheduling - services on the background. Memory usage - programs.) I didn’t have problem with Eclipse, or JEdit. Well I had a little problem when explorer for some reason attempted to discover size of 410 files by reading them into the memory. Swap was filled up to 712 MB and it swapped horribly, but I was able to use jEdit and other programs without really hard problems.

So before disabling the swap file try to use cacheman, and be sure you HD has enabled block read mode and your swap file is unfragmented.
Actually play a little with cacheman settings if you are on windoze. On Linux, look into configuration files and enable read ahead, and UDMA.

[quote]To the swap file disablers. Congratulations on this approach, it’s really bright. O_O
[/quote]
Is that sarcastic? (sorry, I’m not sure).

Why would people be unable to run your game? Are you doing the same as UT and have some bizarre dependency upon swap space?

IIRC on linux you just do “swapoff -a” :). Works a charm. The only difference I’ve noticed compared to windows is that apps only crash this way if they genuinely run out of memory…

Oh, and my HD thrashes considerably less often, which is very nice, (especially if you have a laptop which is otherwise aggressive at powering down the HD).

Yes a little sarkasm in the morning.

Basically it’s the same as with the Alien Flux. I think that windows should know much beter than programmer what they should swap and what not. And my game is a little more memory demanding. Basically 2 GB of memory is nice to have. However 256 - 512 and swap is affordable, and performance is down just by 1/5. 4/5 speed of high memory system is very nice and I don’t need to swap to and from GFX card just to avoid out of memory error.

Well laptops are different beasts, especially if they are disconected from permanent energy source. (Plutonium generator do wonders however.) :slight_smile:

[quote] (Plutonium generator do wonders however.)
[/quote]
I’m not having one of those on my lap!

Raghar - Not really sure why you’d be so against disabling the swap. It works great and besides, I have zero desire to go mucking about with hard drive settings, cache setup, and lots of other gunk, if I can do the same thing with just a few clicks.

I highly doubt windows knows better than I do about when to swap. If they did, they would have another setting which says, don’t swap unless you have used x% of real memory. IMHO. Suppose I was rendering some huge video and decided to minimize the window, so I could check my email. Stupid machine would go grinding my render process to a halt.

The only dif I can see between swapping in a laptop versus a desktop is that the laptop should swap even less to the HD. It sucks extra power to keep transfering stuff back and forth. Surely keeping stuff in ram uses less energy than powering the HD to transfer the data around.

My thoughts anyway! No VRam and loving it!

[rant]
Zero desire to go with setuping your computer? It’s sounds like “I have zero desire to play with the antivirus.”. I think that 2 days per month are part of user responsibilities. Checking CPU temperature, HD cleaning, virus scanning, looking for trojans, and backup are also part of responsibilities when you are using computer. ( I found, just recently, 700 MB backup of FF CD that I completely forgot to delete.) [/rant]
Basically I’m against disallowing of the swap. I have more bad experiences with it, and I don’t remember on any nice experience.
Programs crashing in the worst moment. Programs that refused to run just because they needed a few kB more memory… It doesn’t mean I wouldn’t recommend to use a some kind of fast Flash drive to do actual swapping. It might work great. If you’d have such beast you could consider to use it for your Windows/temp directory as well. 1GB for swap 1GB for virtual temp directory.
Actually it might be very interesting if you have 64 bit processor, 4 GB RAM, and 12 GB Flash drive. (Or if your OS has a virtual 64 bit processor support.)

[quote] Suppose I was rendering some huge video and decided to minimize the window, so I could check my email. Stupid machine would go grinding my render process to a halt.
[/quote]
Did it actually happen? Pretty weird if so. I used Virtdub with enlarged buffers, and lots of other programs as well. It worked well even after minimalisation.
Of course if you used Maya or GMax they are entirely different beasts.

i.e. like me you’ve encountered badly-written crud that throws a wobbly if there’s no swap space.

That doesn’t change the fact that:

  • you don’t want swap
  • you don’t need swap
  • you shouldn’t be using swap

it just means that some of us are forced to have it anyway until we can upgrade to software that was better written :(.

No-one’s suggesting you disable swap if you have too little RAM. e.g. I could go and replace the 0.75Gb of RAM in my windows machine with 32Mb and then of course I need swap just to run windows + MS Word…doesn’t change the fact that the typical PC these days has 0.5-1Gb RAM (unless you bought a cheap-ass thing and didn’t bother to shell out $50 for a RAM upgrade).