Apache karaf 内存不足错误

Apache karaf 内存不足错误

我正在本地在线托管服务的虚拟服务器上工作,我想在其中运行 apache karaf 实例。

在服务器启动期间,我收到内存不足异常:

Exception in thread "Karaf local console user karaf" java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

(请参阅下面的更多细节)

我不知道这是怎么发生的,因为服务器只有 2GB 的可用内存。

使用另一个 ssh-shell 登录时,我有时会收到错误消息

 /usr/bin/lesspipe: 1: /usr/bin/lesspipe: Cannot fork

问题:为什么 karaf 无法完全启动?您将采取哪些步骤来更详细地分析问题?

非常感谢您的支持!


这里还有一些信息:

karaf setenv 文件

export JAVA_MIN_MEM=256M # Minimum memory for the JVM
export JAVA_MAX_MEM=1024M # Maximum memory for the JVM
export JAVA_PERM_MEM=256M # Minimum perm memory for the JVM
export JAVA_MAX_PERM_MEM=1024M # Maximum perm memory for the JVM

输出free -m

             total        used        free      shared  buff/cache       available

Mem:         2048         223        1363           0         461        1824

Swap:          0           0           0

即使在 karaf 服务器停止工作之后,似乎仍然有一些东西留存下来:

top - 16:04:28 up 2 days,  1:09,  2 users,  load average: 0.00, 0.01, 0.05
Tasks:  26 total,   1 running,  25 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.4 sy,  0.0 ni, 99.6 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  2097152 total,  1445120 free,   216712 used,   435320 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  1880340 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND            
 8439 root      20   0   97176   4180   3240 S  0.3  0.2   0:00.34 sshd               
 8793 karaf     20   0 3187104 192736  15088 S  0.3  9.2   0:08.82 java     

cat /proc/sys/kernel/threads-max

3092863

ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1546431
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 62987
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

猫/ proc / user_beancounters

Version: 2.5
       uid  resource                     held              maxheld              barrier                limit              failcnt
   2810691: kmemsize                 73211904             74088448  9223372036854775807  9223372036854775807                    0
            lockedpages                     0                    0  9223372036854775807  9223372036854775807                    0
            privvmpages                120109               126756  9223372036854775807  9223372036854775807                    0
            shmpages                      277                 2064  9223372036854775807  9223372036854775807                    0
            dummy                           0                    0  9223372036854775807  9223372036854775807                    0
            numproc                        78                   78                  400                  400                    0
            physpages                  214852               219387               524288               524288                    0
            vmguarpages                     0                    0  9223372036854775807  9223372036854775807                    0
            oomguarpages               216059               220594                    0                    0                    0
            numtcpsock                      0                    0  9223372036854775807  9223372036854775807                    0
            numflock                        7                   15  9223372036854775807  9223372036854775807                    0
            numpty                          4                    5  9223372036854775807  9223372036854775807                    0
            numsiginfo                      0                  123  9223372036854775807  9223372036854775807                    0
            tcpsndbuf                       0                    0  9223372036854775807  9223372036854775807                    0
            tcprcvbuf                       0                    0  9223372036854775807  9223372036854775807                    0
            othersockbuf                    0                    0  9223372036854775807  9223372036854775807                    0
            dgramrcvbuf                     0                    0  9223372036854775807  9223372036854775807                    0
            numothersock                    0                    0  9223372036854775807  9223372036854775807                    0
            dcachesize               55529472             55709696  9223372036854775807  9223372036854775807                    0
            numfile                       966                 1395  9223372036854775807  9223372036854775807                    0
            dummy                           0                    0  9223372036854775807  9223372036854775807                    0
            dummy                           0                    0  9223372036854775807  9223372036854775807                    0
            dummy                           0                    0  9223372036854775807  9223372036854775807                    0
            numiptent                      36                   36                 2000                 2000                    0

DF-H

/dev/ploop11992p1   51G  2.1G   46G   5% /
none               1.0G     0  1.0G   0% /sys/fs/cgroup
none               1.0G     0  1.0G   0% /dev
tmpfs              1.0G     0  1.0G   0% /dev/shm
tmpfs              1.0G  1.1M 1023M   1% /run
tmpfs              5.0M     0  5.0M   0% /run/lock
none               1.0G     0  1.0G   0% /run/shm

memory.log 的内容

Number of objects waiting finalization: 0

Heap:
    Init:      268435456
    User:      63690360
    Committed: 259588096
    Max:       1037959168
Non-Heap: 
    Init:      7667712
    User:      60647112
    Committed: 68009984
    Max:       -1

长错误消息

  Apache Karaf (4.2.5)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

[7,773s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
[7,794s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
Exception in thread "Karaf local console user karaf" java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
    at java.base/java.lang.Thread.start0(Native Method)
    at java.base/java.lang.Thread.start(Thread.java:803)
    at java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:937)
    at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1354)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
    at org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.start(CommandSessionImpl.java:799)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:300)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:169)
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:149)
    at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:179)
    at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.doExecuteScript(ConsoleSessionImpl.java:578)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.executeScript(ConsoleSessionImpl.java:570)
    at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:401)
    at java.base/java.lang.Thread.run(Thread.java:834)

[76,701s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
OpenJDK 64-Bit Server VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal SIGWINCH to handler- the VM may need to be forcibly terminated
[78,236s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
OpenJDK 64-Bit Server VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal SIGWINCH to handler- the VM may need to be forcibly terminated

答案1

令人惊讶的答案:这是 karaf,降级到 Java 9 后一切都正常运行。

相关内容