Problem running my java app on Netbeans

E

Enter The

I am using a computer with 6.0g ram, on Windows Vista Business 64-bit.

In Netbeans, I have set my VM Options to -Xmx1g. It works.
If I set the vm options to -Xmx2g it does not work. I get this error:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Why does this happen when I have 6 gigs of ram? I frequently run
System.gc() to reduce the memory used. I have tried turning off the
vista Superfetch to reduce memory usage, but that has not helped. I
currently have 3gb free (shown by task manager) but it won't start).

my java version is

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
 
M

Mike Schilling

Enter said:
I am using a computer with 6.0g ram, on Windows Vista Business 64-bit.

In Netbeans, I have set my VM Options to -Xmx1g. It works.
If I set the vm options to -Xmx2g it does not work. I get this error:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Why does this happen when I have 6 gigs of ram? I frequently run
System.gc() to reduce the memory used. I have tried turning off the
vista Superfetch to reduce memory usage, but that has not helped. I
currently have 3gb free (shown by task manager) but it won't start).

my java version is

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Is Netbeans using a 64-bit JDK? It's quite possible )though I don't know
for sure) that a 32-bit JDK can't manage 2GB of heap.
 
L

Lew

Enter said:
I frequently run System.gc() to reduce the memory used.

Use of System.gc() is an antipattern most of the time, the more so if you use
it frequently. It also has nothing whatsoever to do with the JVM's ability to
allocate memory from the OS. Your error message:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
proves that there never even was an opportunity to invoke System.gc(), even
were it to do some good, which it wouldn't.

Mike is correct that a 32-bit JVM is limited to somewhat less than 2 GB heap,
the exact limit depending on the OS. It's also necessary that the JVM
allocate contiguous memory, AIUI. OSes sometimes fragment allocations.

The amount of RAM that the OS shows the JVM to use is only tangentially
related to the amount of free heap controlled by the JVM within itself.
 
M

Mike Schilling

..
Mike is correct that a 32-bit JVM is limited to somewhat less than 2 GB
heap, the exact limit depending on the OS. It's also necessary that the
JVM allocate contiguous memory, AIUI.

I don't know why that would be,. A non-contiguous heap can be modeled
simply as a contiguous heap with allocations already taken out of its
middle. I'm not saying you're wrong, just that it's an odd requirement.
 
A

Arne Vajhøj

I don't know why that would be,

It does not have to be that way.

But it is my understanding that BEA (now Oracle) JRockit
is the only x86 32 bit JVM, that support non contigious
heap (which for some reason is synonymous with supporting
the /3GB switch for Windows).

Given that the world is at full speed towards 64 bit, then the
problem will disappear in some years.

Arne
 
M

Mike Schilling

Arne said:
It does not have to be that way.

But it is my understanding that BEA (now Oracle) JRockit
is the only x86 32 bit JVM, that support non contigious
heap (which for some reason is synonymous with supporting
the /3GB switch for Windows).

Almost certainly because Windows puts things at fixed places in the 4GB
32-bit virtual address space that makes 3GB of contiguous virtual space
unavailable. Since the NT family is in some ways a descendent of VMS, I'd
guess that 3GB would amount to the first two GB and the last GB [1], with
the third GB [2] used to map stuff common to all processes.

1. That is, P0, P1, and S1 space.
2. S0 space.
 
A

Arne Vajhøj

Arne said:
It does not have to be that way.

But it is my understanding that BEA (now Oracle) JRockit
is the only x86 32 bit JVM, that support non contigious
heap (which for some reason is synonymous with supporting
the /3GB switch for Windows).

Almost certainly because Windows puts things at fixed places in the 4GB
32-bit virtual address space that makes 3GB of contiguous virtual space
unavailable. Since the NT family is in some ways a descendent of VMS, I'd
guess that 3GB would amount to the first two GB and the last GB [1], with
the third GB [2] used to map stuff common to all processes.

1. That is, P0, P1, and S1 space.
2. S0 space.

They could have done it that way, but they did not.

/3GB expands userspace from 00000000-7FFFFFFF to 00000000-BFFFFFFF.

Arne
 
R

Roedy Green

I am using a computer with 6.0g ram, on Windows Vista Business 64-bit.

In Netbeans, I have set my VM Options to -Xmx1g. It works.
If I set the vm options to -Xmx2g it does not work. I get this error:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Why does this happen when I have 6 gigs of ram? I frequently run
System.gc() to reduce the memory used. I have tried turning off the
vista Superfetch to reduce memory usage, but that has not helped. I
currently have 3gb free (shown by task manager) but it won't start).

my java version is

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

The equivalent problem with IntelliJ can be fixed by telling IntelliJ
to use 64-bit Java and a 64-bit OS. With a 32-bit Java all kinds of
stuff has to fit in that 32-bit address space besides the heap.
--
Roedy Green Canadian Mind Products
http://mindprod.com

The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair.
~ Douglas Adams (born: 1952-03-11 died: 2001-05-11 at age: 49)
 
R

Roedy Green

Almost certainly because Windows puts things at fixed places in the 4GB

When a new address space is introduced, it seems infinitely big, and
there is a tendency to nail down great chunks of it for stuff that has
questionable long term utility.

It would be interesting to see a map of just how those 32 addressing
bits end up being allocated in a real world situation, perhaps a pie
chart.

--
Roedy Green Canadian Mind Products
http://mindprod.com

The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair.
~ Douglas Adams (born: 1952-03-11 died: 2001-05-11 at age: 49)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top