Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

It is clear in this Question

Fail to start Glassfish 3.1: java.io.IOException: error=12, Cannot allocate memory

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

share|improve this question
    
What's the output of free -m –  Cakemox Feb 1 '11 at 11:53
    
How to do for "output of free -m"? –  Shisoft Feb 1 '11 at 12:06
    
Type "free -m" at the shell prompt. –  Cakemox Feb 1 '11 at 12:09
    
What's the output 'cat /proc/user_beancounters' –  alvosu Feb 1 '11 at 12:51
    
@alvosu have you seen that,thanks –  Shisoft Feb 13 '11 at 9:30
add comment

1 Answer

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()?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.