Max VM memory size

I’m hitting OutOfMemory exceptions in my app when I use terrains of size 512x512. (more specifically, when trying to create a float ByteBuffer). So I whack in a -Xmx80m (straight from the javadoc) and see how it goes… same result.

In fact even going up to a ‘max’ of 1024 doesn’t solve things, so either:

  • I’m blind and not using the command line arg properly.
  • The new memory limit is being ignored for some reason
  • Theres some arbitrary limit on ByteBuffers that I’ve not found the right option to tweek.

Anyone any hints?

The memory for direct byte buffers doesn’t come from the heap.

Ok, so how do I tweek things so I can allocate more to whereever they’re allocated from?

[quote]Ok, so how do I tweek things so I can allocate more to whereever they’re allocated from?
[/quote]
This is timely. I’ve been doing a lot of work recently related to address space allocations in the JVM. In any case, what you’re looking for is -XX:MaxDirectMemorySize=. The memory doesn’t come from the heap and doesn’t share address space with the heap, although it does, of course, take from the total address space of the process.

God bless,
-Toby Reyelts