VolatileImage & Heap Space

I am noticing something odd about the behavior of the VolatileImage class in my game. I am using a Frame with a BufferStrategy in exclusive screen mode on Windows machines. I want to use a pretty good amount of VRAM and manage that directly with VolatileImage objects.

When my game is put into the background - using the Windows key, for instance - the heap space spikes quite noticeably. It seems that the JVM wants to preserve the VoltileImage surfaces by copying them back into system memory.

My question is: can I do something to prevent this? Obviously, because my application is a game I am happy to manage restoring the VolatileImage objects’ surface myself. And, of course, there is no reason to do that when the game is minimized anyway.

All of this seems to happen BEFORE my frame receives the windowDeactivated message, by the way.

Any ideas?

Thanks!

The point of VolatileImage is that it has no system RAM backing store - you’re supposed to be keeping a copy yourself, if you want it to be preserved (which is how BufferedImage works, I believe - it punts its system RAM image into a VolatileImage to accelerate blitting operations until you use a rendering path that doesn’t support it or you try and read back from the image).

If your system RAM usage is going up regardless, perhaps your drivers are for a “shared RAM” architecture? Don’t know without a little more information.

Cas :slight_smile:

Thanks, Cas.

[quote]The point of VolatileImage is that it has no system RAM backing store
[/quote]
Of course you are right. And that’s what has me puzzled. My machine does have an integrated graphics chip but I don’t have a driver installed for it and I use a stand-alone card. But your suggestion has gotten me thinking. I should do some testing with one of my other machines to see if I can duplicate this behavior.

I’ll check that and report my results.

Well, the short answer is that my original idea was silly and volatile images are working exactly as they should.

The longer answer is that I was apparently misunderstanding the behavior of the garbage collector. When I use volatile images for certain things my game is producing more garbage. It’s using less memory because the images aren’t kept after making the volatile surfaces.

Sorry to waste everyone’s time. :frowning:

No problem - and these sorts of threads are useful things to have lying around on forums for Google to index.

Cas :slight_smile: