1

It is clear in this Question

https://serverfault.com/questions/210275/fail-to-start-glassfish-3-1-java-io-ioexception-error-12-cannot-allocate-mem

But in my case,I have a 512M memory Ubuntu 10.04 vps.It seems that I don't need to change any configure.But when start the server,I got this exception

VM failed to start: java.io.IOException: Cannot run program "/usr/lib/jvm/java-6-sun-1.6.0.22/bin/java" (in directory "/home/glassfish/glassfish/domains/domain1/config"): java.io.IOException: error=12, Cannot allocate memory

So,I set

<jvm-options>-Xmx512</jvm-options>

to

<jvm-options>-Xmx400</jvm-options>

The exception remains.What did I do something wrong?

result of free -m

             total       used       free     shared    buffers     cached
Mem:           512         43        468          0          0          0
-/+ buffers/cache:         43        468
Swap:            0          0          0

result of cat /proc/user_beancounters

Version: 2.5
       uid  resource                     held              maxheld              barrier                limit              failcnt
   146049:  kmemsize                  2670652              5385253             51200000             51200000                    0
            lockedpages                     0                    8                 2048                 2048                    0
            privvmpages                 11134               134522               131200               262200                    4
            shmpages                      648                 1352               128000               128000                    0
            dummy                           0                    0                    0                    0                    0
            numproc                        12                   73                  500                  500                    0
            physpages                    6519                28162                    0            200000000                    0
            vmguarpages                     0                    0               512000               512000                    0
            oomguarpages                 6527                28169               512000               512000                    0
            numtcpsock                      4                   14                 4096                 4096                    0
            numflock                        0                    5                 2048                 2048                    0
            numpty                          1                    2                   32                   32                    0
            numsiginfo                      0                    3                 1024                 1024                    0
            tcpsndbuf                  159600               265744             20480000             20480000                    0
            tcprcvbuf                   65536              3590352             20480000             20480000                    0
            othersockbuf                44232                90640             20480000             20480000                    0
            dgramrcvbuf                     0                12848             10240000             10240000                    0
            numothersock                   22                   31                 2048                 2048                    0
            dcachesize                      0                    0             10240000             10240000                    0
            numfile                      1002                 1474                50000                50000                    0
            dummy                           0                    0                    0                    0                    0
            dummy                           0                    0                    0                    0                    0
            dummy                           0                    0                    0                    0                    0
            numiptent                      24                   24                 2048                 2048                    0

Thanks

Shisoft
  • 161
  • 1
  • 11

1 Answers1

0

Keep in mind that Java requires that heap space be allocated from one contiguous memory space, so your memory may be fragmented to the point where the process cannot acquire a space big enough to initialize (although it will not allocate the -Xmx or even the -Xms amount of memory right off the bat.

See this stackoverflow post for one potential solution:

How to solve “java.io.IOException: error=12, Cannot allocate memory” calling Runtime#exec()?

Nicholas
  • 207
  • 1
  • 7