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

Discussion in 'Java' started by Dundonald, Dec 21, 2007.

  1. Dundonald

    Dundonald Guest

    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
     
    Dundonald, Dec 21, 2007
    #1
    1. Advertising

  2. Dundonald

    Daniel Pitts Guest

    Dundonald wrote:
    > 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)


    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
     
    Daniel Pitts, Dec 21, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Young-Jin Lee

    MS JVM and Sun JVM problem

    Young-Jin Lee, Jan 20, 2004, in forum: Java
    Replies:
    3
    Views:
    575
    Mickey Segal
    Jan 21, 2004
  2. Fatih
    Replies:
    4
    Views:
    13,908
    Fatih
    Apr 9, 2004
  3. adgarcia13
    Replies:
    2
    Views:
    3,965
    Gordon Beaton
    Jun 28, 2006
  4. Ken
    Replies:
    24
    Views:
    3,876
    Ben Bacarisse
    Nov 30, 2006
  5. chris
    Replies:
    6
    Views:
    993
    chris
    Oct 28, 2005
Loading...

Share This Page