c12
c12

Reputation: 9827

Check Java JVM Memory Limit on Windows XP

I want to see how much memory is allocated to my Java JVM on my Windows XP installation. I'm running an executable jar that has a main class that makes some JNI calls to a C library via a dll that is loaded using the System.loadLibrary("SampleJni"). Some calls are working and some are not. Whenever there are more than one String parameters passed I get a system dump. If I just have one String, one int, two ints..etc, no crashes. The machine only has .99 GB of ram, so I'm thinking the JVM can't allocate the need memory.

Upvotes: 2

Views: 460

Answers (2)

BillRobertson42
BillRobertson42

Reputation: 12883

I've run JVMs (Java 6) on machines with less memory than that. IIRC the default for the JVM on windows was 64Mb, but that may have changed. Even if it did, it should be enough to start up. You'd also see OutOfMemoryErrors if this were the case rather than hard crashes.

There are various methods in java.lang.Runtime that will let you inspect how much memory you have.

The likely cause is the JNI interface. Its very easy to crash the JVM if the JNI code isn't 100% correct.

Upvotes: 0

chubbsondubs
chubbsondubs

Reputation: 38852

Use jconsole to check the memory used by your program. Jconsole comes with the JDK so you already have it. This memory won't include memory used by your JNI C code, but it will tell you what memory Java is using. Your more likely culprit is JNI mapping isn't correct when using multiple parameters.

Upvotes: 2

Related Questions