Problem with memory (unix) allocation to JVM running Java program

D

Dundonald

I'm attempting to run a very simple Java program on unix box using
command:

java -jar HelloWorld.jar

and experience the following error

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

If I run the "top" and "free" unix commands I can't see why there
might be a problem freeing up memory to allocate to the JVM, unless
I'm missing something obvious. Any ideas please help. Thanks.

See below for "top" and "free" output:

top:

top - 07:57:22 up 21 days, 14:42, 3 users, load average: 0.16, 0.07,
0.02
Tasks: 46 total, 1 running, 45 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.1% us, 0.1% sy, 0.0% ni, 99.8% id, 0.0% wa, 0.0% hi,
0.0% si
Mem: 6097220k total, 6081344k used, 15876k free, 12584k
buffers
Swap: 12586916k total, 6277504k used, 6309412k free, 355436k
cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
1 root 16 0 1628 516 492 S 0 0.0 0:03.66
init
30158 root 15 0 1532 512 444 S 0 0.0 0:08.01
syslogd
30175 root 16 0 4012 796 708 S 0 0.0 0:11.42
sshd
30193 root 18 0 2080 600 596 S 0 0.0 0:00.00
xinetd
30209 root 16 0 3716 296 260 S 0 0.0 0:00.00
vsftpd
30285 root 18 0 2152 896 892 S 0 0.0 0:00.00
mysqld_safe
30331 mysql 16 0 123m 4856 3036 S 0 0.1 1:02.25
mysqld
30508 cyrus 16 0 4424 960 860 S 0 0.0 0:01.50 cyrus-
master
30523 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30524 cyrus 17 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30525 cyrus 18 0 29192 1488 1484 S 0 0.0 0:00.00
pop3d
30527 cyrus 18 0 29192 1484 1484 S 0 0.0 0:00.00
pop3d
30533 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30535 cyrus 18 0 29192 1488 1484 S 0 0.0 0:00.00
pop3d
30626 root 16 0 5104 1344 1264 S 0 0.0 0:01.01
master
30636 postfix 15 0 5204 1352 1292 S 0 0.0 0:00.11
nqmgr
30645 cyrus 17 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30646 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30647 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30648 cyrus 17 0 29192 1488 1484 S 0 0.0 0:00.00
pop3d
30704 root 23 0 296m 39m 4120 S 0 0.7 4:42.30
java
31817 root 16 0 49580 15m 7848 S 0 0.3 0:16.25
httpd
31837 root 16 0 2480 592 544 S 0 0.0 0:00.06
crond
31867 root 18 0 4052 540 536 S 0 0.0 0:00.00
saslauthd
31868 root 18 0 4052 228 224 S 0 0.0 0:00.00
saslauthd
20271 tomcat 17 0 452m 79m 4592 S 0 1.3 11:32.21
java
32765 cyrus 18 0 29328 1652 1648 S 0 0.0 0:00.00
lmtpd
7501 root 16 0 39384 6156 140 S 0 0.1 0:00.00
httpd
7510 apache 15 0 49692 10m 2648 S 0 0.2 0:00.15
httpd
13886 apache 15 0 49724 10m 2676 S 0 0.2 0:00.12
httpd
13908 apache 15 0 49724 10m 2636 S 0 0.2 0:00.15
httpd
11293 root 17 0 6632 1980 1628 S 0 0.0 0:00.01
sshd

free:

total used free shared buffers
cached
Mem: 6097220 6081544 15676 0 30924
356504
-/+ buffers/cache: 5694116 403104
Swap: 12586916 6277504 6309412
 
D

Daniel Pitts

Dundonald said:
I'm attempting to run a very simple Java program on unix box using
command:

java -jar HelloWorld.jar

and experience the following error

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

If I run the "top" and "free" unix commands I can't see why there
might be a problem freeing up memory to allocate to the JVM, unless
I'm missing something obvious. Any ideas please help. Thanks.

See below for "top" and "free" output:

top:

top - 07:57:22 up 21 days, 14:42, 3 users, load average: 0.16, 0.07,
0.02
Tasks: 46 total, 1 running, 45 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.1% us, 0.1% sy, 0.0% ni, 99.8% id, 0.0% wa, 0.0% hi,
0.0% si
Mem: 6097220k total, 6081344k used, 15876k free, 12584k
buffers
Swap: 12586916k total, 6277504k used, 6309412k free, 355436k
cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
1 root 16 0 1628 516 492 S 0 0.0 0:03.66
init
30158 root 15 0 1532 512 444 S 0 0.0 0:08.01
syslogd
30175 root 16 0 4012 796 708 S 0 0.0 0:11.42
sshd
30193 root 18 0 2080 600 596 S 0 0.0 0:00.00
xinetd
30209 root 16 0 3716 296 260 S 0 0.0 0:00.00
vsftpd
30285 root 18 0 2152 896 892 S 0 0.0 0:00.00
mysqld_safe
30331 mysql 16 0 123m 4856 3036 S 0 0.1 1:02.25
mysqld
30508 cyrus 16 0 4424 960 860 S 0 0.0 0:01.50 cyrus-
master
30523 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30524 cyrus 17 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30525 cyrus 18 0 29192 1488 1484 S 0 0.0 0:00.00
pop3d
30527 cyrus 18 0 29192 1484 1484 S 0 0.0 0:00.00
pop3d
30533 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30535 cyrus 18 0 29192 1488 1484 S 0 0.0 0:00.00
pop3d
30626 root 16 0 5104 1344 1264 S 0 0.0 0:01.01
master
30636 postfix 15 0 5204 1352 1292 S 0 0.0 0:00.11
nqmgr
30645 cyrus 17 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30646 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30647 cyrus 18 0 29420 1488 1484 S 0 0.0 0:00.00
imapd
30648 cyrus 17 0 29192 1488 1484 S 0 0.0 0:00.00
pop3d
30704 root 23 0 296m 39m 4120 S 0 0.7 4:42.30
java
31817 root 16 0 49580 15m 7848 S 0 0.3 0:16.25
httpd
31837 root 16 0 2480 592 544 S 0 0.0 0:00.06
crond
31867 root 18 0 4052 540 536 S 0 0.0 0:00.00
saslauthd
31868 root 18 0 4052 228 224 S 0 0.0 0:00.00
saslauthd
20271 tomcat 17 0 452m 79m 4592 S 0 1.3 11:32.21
java
32765 cyrus 18 0 29328 1652 1648 S 0 0.0 0:00.00
lmtpd
7501 root 16 0 39384 6156 140 S 0 0.1 0:00.00
httpd
7510 apache 15 0 49692 10m 2648 S 0 0.2 0:00.15
httpd
13886 apache 15 0 49724 10m 2676 S 0 0.2 0:00.12
httpd
13908 apache 15 0 49724 10m 2636 S 0 0.2 0:00.15
httpd
11293 root 17 0 6632 1980 1628 S 0 0.0 0:00.01
sshd

free:

total used free shared buffers
cached
Mem: 6097220 6081544 15676 0 30924
356504
-/+ buffers/cache: 5694116 403104
Swap: 12586916 6277504 6309412
I've had similar problems in NetBSD when I didn't properly set the
memory using ulimit. I don't remember the details, but it basically was
set to "unlimited" and that let the JVM think it could allocated
infinity :)

Also, try playing with the -X setting (java -X for more help)
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top