High memory consumption?

Hey,

just noticed that when I start up my game the new java process takes above 2GB or memory at its peak. I have really simple graphics and have no clue if it really means 2GB of memory usage.

When I print the memory usage info using KEY_M it displays this:
Existing buffers: 10851
(b: 1623 f: 6512 i: 0 s: 2716 d: 0)
Total heap memory held: 965057kb
Total direct memory held: 869901kb
(b: 868956kb f: 828kb i: 0kb s: 116kb d: 0kb)

How is it to be understood? Am I really in trouble now?
Thanks for any input,
Adam.

Whoah… you say “really simple graphics” and yet according to those stats you are using almost 1 gig of heap and 1 gig of direct memory.

I think we/you need to drill in a little bit more on what “really simple graphics” means.

Actually I just reduced it to less than half of it. High resolution images used in nifty gui take a lot of memory…

@jadam said: Actually I just reduced it to less than half of it. High resolution images used in nifty gui take a lot of memory...

Cool, still, that’s quite high if you say your graphics are simple. Mythruna uses just a little over a gig when clip is fully extended and that’s a pretty complicated scene. I even cap my heap at 512 meg.

@pspeed said: Cool, still, that's quite high if you say your graphics are simple. Mythruna uses just a little over a gig when clip is fully extended and that's a pretty complicated scene. I even cap my heap at 512 meg.
How is it possible that when I press M it says ~300MB heap space and ~300MB direct memory, yet the process in task manager takes 950MB?
@jadam said: How is it possible that when I press M it says ~300MB heap space and ~300MB direct memory, yet the process in task manager takes 950MB?

Because java allocates memory up to max heap, then it manages the contents of that memory itself.

@jmaasing said: Because java allocates memory up to max heap, then it manages the contents of that memory itself.

No… it allocates as needed. But it uses memory to manage its memory. The actual OS use will always be higher.

It will allocate up to the “min” heap size… maybe that’s what you were thinking of.

OP: Anyway, I’m still curious what your scene actually is. You say it’s simple but your stats say otherwise. This makes me wonder if there is a an error or something somewhere. Things getting loaded twice, inefficient scene/models, or something else.

@pspeed said: No... it allocates as needed. But it uses memory to manage its memory. The actual OS use will always be higher.

It will allocate up to the “min” heap size… maybe that’s what you were thinking of.

OP: Anyway, I’m still curious what your scene actually is. You say it’s simple but your stats say otherwise. This makes me wonder if there is a an error or something somewhere. Things getting loaded twice, inefficient scene/models, or something else.


I have a huge map (a simple quad) with texture 12000*6000 and a few thousand region indicators. The region indicators are not loaded when they are not visible. I guess most of the memory is that map with that texture.

@pspeed said: No... it allocates as needed. But it uses memory to manage its memory. The actual OS use will always be higher.

It will allocate up to the “min” heap size… maybe that’s what you were thinking of.

OP: Anyway, I’m still curious what your scene actually is. You say it’s simple but your stats say otherwise. This makes me wonder if there is a an error or something somewhere. Things getting loaded twice, inefficient scene/models, or something else.

Oh, I didn’t know that it released memory back to the OS efter it had grabbed it once, you live and learn :slight_smile:
What I meant to say was it grabs memory, as needed, up to max, but not all of that memory is the same as available heap, java manages that memory itself i.e. the amount of memory the OS gave it is not the same as available heap.

As you say, that’s beside the point to the OP :slight_smile: In a simple app that much memory shouldn’t be needed.

@jadam said: I have a huge map (a simple quad) with texture 12000*6000 and a few thousand region indicators. The region indicators are not loaded when they are not visible. I guess most of the memory is that map with that texture.
is that 12000*6000 pixels * 4 bytes RGBA = 288 000 000 bytes of texture memory? I think that answers it :)

Also with mipmaps, it will be more than 288 … It will be 288 MB + 72 + 18 + 4.5 + …

With DXT1 texture compression you can lower that to 36 MB + 9 + 2.5 + …, assuming the texture doesn’t have an alpha channel.

@Momoko_Fan said: Also with mipmaps, it will be more than 288 .. It will be 288 MB + 72 + 18 + 4.5 + ...

With DXT1 texture compression you can lower that to 36 MB + 9 + 2.5 + …, assuming the texture doesn’t have an alpha channel.


It does not have an alpha channel, just googled DXT1, but how do you use it with jMonkey, could you suggest some info on that, please?

Nevermind it, thanks a lot for the tip it works great, now my total memory consumption is below 500MB.
I used ATI’s Compressonator to compress my texture into DXT1: http://developer.amd.com/resources/archive/archived-tools/gpu-tools-archive/the-compressonator/ .

Thanks again a lot!

For advanced own tooling stuff:
The nasa worldwind code has a ddsconverter in it, wich is possible to use (and just ignoring the worldwind bloat).

Reason for diving into this was, that I needed to convert a 6*4k skybox (I hate it when they look low res when you zoom in with weapons ect)
Both the ati and the nvidia toool regulary roun ot of 32bit memory, while the worldwind stuff can run witha 64bit jvm and I’m fine.

just a sidebar note, dxt1 textures dont work on all hardware (mainly systems with integrated graphics i believe). only reason i know this is because they dont work on my laptop :D.

I’d only use dxt1 textures if its a texture that could just be discarded if its not supported. Using for a menu interface could completely kill the game for people when they would otherwise be fully capable of running it.

Well dxt works for any normal graficcard, so if you dont target the low power computers its fine. Even the current intel chips can support it fine. However if you use the stock windows/linux drivers support is limited.

well i guess its up to each developer do decide whats best for his or her game. i just wanted to provide a caveat in the thread for anyone reading it that its not a cross platform solution.