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?

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.

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.

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?

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?

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 (yours truly had to support a family member trying to run it and discovered this calamity of incompetence ).

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

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.

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...

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.

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.

To the swap file disablers. Congratulations on this approach, it's really bright. O_O

Is that sarcastic? (sorry, I'm not sure).

Quote

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.).

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

Quote

On Linux, look into configuration files and enable read ahead, and UDMA.

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).

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.) ^_^

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.

[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.

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.

Basically I'm against disallowing of the swap. I have more bad experiences with it, and I don't remember on any nice experience.

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 .

Quote

Programs that refused to run just because they needed a few kB more memory

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).

Of course if you need 2 or more GB of RAM life is a bit more expensive. Then you probably have to use the more expensive and usually slower 1GB RAM modules. I only need this sort of space occasionally, so swapping is appropriate.

The big difference between a native application swapping out and a java application swapping out, is that java also swaps out the whole VM with the application. so, if you are trying to accomdate the "look and feel" of a platform, obviously waiting considerably more time for a java application to swap the VM (which should be thought of as system level code in many circumstances) and application back in doesn't cut it (at least on winbloze.) at a minimum, i'd love to see the VM implementors provide some runtime switches that allow the deployer to mark pages used by the VM as non-pageable.

Actually the really irritating bit is that often a large part of what is swapped out and then back in is garbage. Since swapping is such a slow operation it would be great to somehow interact with the collector to GC and possibly reduce the allocated heap before deciding to swap. But the implementations of virtual memory are too low level for that to work.

Garbage collection and swapfiles are a mingling of two completely incompatible concepts. A bit like using virtual memory for disk cacheing - pointless. If you're going to use garbage collection you need to be pretty sure that the heap won't get swapped out or it is inevitable that performance will be absolutely hopeless next to a native application.

I don't think the VM being swapped out is such a big deal but it makes sound sense to put it into a nonpaged area, or even in the kernel nonpaged area.

I spoke with a friend here at work and he turned his off. Later he turned it back on, since he was running out of ram often. He's the type of user who runs so many apps at the same time, you can barely click between the app buttons on the task bar, as there so small. For him, he agreed that not using the swap was faster, but he was willing to 'bear the pain' of having his programs swap in and out, rather than stop running 500 apps at the same time.

I wonder why MS doesn't just make their swap usage more agressive, by starting with a much smaller swap size and only increasing it when physical ram is at say 75% usage. At least then it would make a bit more sense. IMHO.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org