我使用1多線程程序,並返回內存不足錯誤。我已經設置爲4000M內存,但仍然返回內存。Java多線程內存不足
即啓動此程序的參數是象下面這樣:
/common/packages/8.1.1/java/jdk1.6.0_38/bin/java -jar -d64 -XX:MaxPermSize=4000M -Xms4000M -Xmx4000M batchReserveNumbersReflectStatus.jar
下面是多線程的源代碼
ThreadPoolExecutor executor;
int maxThreadQ = 0;
maxThreadQ = 10000;
BlockingQueue queue = new ArrayBlockingQueue(maxThreadQ);
Runnable task=null;
executor = new ThreadPoolExecutor(Integer.parseInt(20),Integer.parseInt(20),2400,TimeUnit.MILLISECONDS, queue);
下面是錯誤的細節。
bash-3.2$ tail -200 hs_err_pid2321.log
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 5464064 bytes for card table expansion
# Possible reasons:
# The system is out of physical RAM or swap space
# In 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 bit OS
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (cardTableModRefBS.cpp:290), pid=2321, tid=2
#
# JRE version: 6.0_38-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.13-b02 mixed mode solaris-sparc compressed oops)
--------------- T H R E A D ---------------
Current thread (0x0000000100117000): JavaThread "Unknown thread" [_thread_in_vm, id=2, stack(0xffffffff7ba00000,0xffffffff7bb00000)]
Stack: [0xffffffff7ba00000,0xffffffff7bb00000], sp=0xffffffff7bafec80, free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x9b24ac] void VMError::report_and_die()+0x75c
V [libjvm.so+0x514844] void report_vm_out_of_memory(const char*,int,unsigned long,const char*)+0x64
V [libjvm.so+0x2ae6b8] void CardTableModRefBS::resize_covered_region(MemRegion)+0x1c0
V [libjvm.so+0x2ae348] void CardTableExtension::resize_covered_region(MemRegion)+0xe8
V [libjvm.so+0x2c3c44] void PSOldGen::initialize_work(const char*,int)+0xa4
V [libjvm.so+0x8a2920] void PSOldGen::initialize(ReservedSpace,unsigned long,const char*,int)+0xc8
V [libjvm.so+0x35de58] AdjoiningGenerations::AdjoiningGenerations #Nvariant 1(ReservedSpace,unsigned long,unsigned long,unsigned long,unsigned long,unsigned long,unsigned long,unsigned long)+0x2a8
V [libjvm.so+0x2d1d84] int ParallelScavengeHeap::initialize()+0x4bc
V [libjvm.so+0x96fc7c] int Universe::initialize_heap()+0x224
V [libjvm.so+0x2e0b90] int universe_init()+0x118
V [libjvm.so+0x2cea04] int init_globals()+0xac
V [libjvm.so+0x95bad0] int Threads::create_vm(JavaVMInitArgs*,bool*)+0x238
V [libjvm.so+0x2dc0f4] JNI_CreateJavaVM+0x74
C [java+0x2778]
[error occurred during error reporting (printing native stack), id 0xb]
--------------- P R O C E S S ---------------
Java Threads: (=> current thread)
Other Threads:
=>0x0000000100117000 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=2, stack(0xffffffff7ba00000,0xffffffff7bb00000)]
VM state:not at safepoint (not fully initialized)
VM Mutex/Monitor currently owned by a thread: None
Dynamic libraries:
0x0000000100000000 /common/packages/8.1.1/java/jdk1.6.0_38/bin/sparcv9/java
0xffffffff7f200000 /lib/64/libthread.so.1
0xffffffff7ef00000 /common/packages/8.1.1/java/jdk1.6.0_38/bin/sparcv9/../../jre/lib/sparcv9/jli/libjli.so
0xffffffff7ed00000 /lib/64/libdl.so.1
0xffffffff7e900000 /lib/64/libc.so.1
0xffffffff7f000000 /platform/SUNW,T5240/lib/sparcv9/libc_psr.so.1
0xffffffff7d800000 /common/packages/8.1.1/java/jdk1.6.0_38/jre/lib/sparcv9/server/libjvm.so
0xffffffff7d600000 /lib/64/libsocket.so.1
0xffffffff7e700000 /usr/lib/64/libsched.so.1
0xffffffff7d400000 /lib/64/libm.so.1
0xffffffff7d200000 /usr/lib/64/libCrun.so.1
0xffffffff7d000000 /lib/64/libdoor.so.1
0xffffffff7ce00000 /usr/lib/64/libdemangle.so.1
0xffffffff7cc00000 /lib/64/libkstat.so.1
0xffffffff7ca00000 /lib/64/libnsl.so.1
0xffffffff7c800000 /lib/64/libm.so.2
0xffffffff7c600000 /lib/64/libmp.so.2
0xffffffff7c400000 /lib/64/libmd.so.1
0xffffffff7c200000 /platform/SUNW,T5240/lib/sparcv9/libmd_psr.so.1
0xffffffff7c000000 /lib/64/libscf.so.1
0xffffffff7be00000 /lib/64/libuutil.so.1
0xffffffff7bc00000 /lib/64/libgen.so.1
0xffffffff7b800000 /common/packages/8.1.1/java/jdk1.6.0_38/jre/lib/sparcv9/libverify.so
0xffffffff7b600000 /common/packages/8.1.1/java/jdk1.6.0_38/jre/lib/sparcv9/libjava.so
0xffffffff7b400000 /common/packages/8.1.1/java/jdk1.6.0_38/jre/lib/sparcv9/libzip.so
VM Arguments:
jvm_args: -XX:MaxPermSize=4000M -Xms4000M -Xmx4000M
java_command: batchReserveNumbersReflectStatus.jar
Launcher Type: SUN_STANDARD
Environment Variables:
PATH=/usr/bin:
LD_LIBRARY_PATH=/common/packages/8.1.1/java/jdk1.6.0_38/jre/lib/sparcv9/server:/common/packages/8.1.1/java/jdk1.6.0_38/jre/lib/sparcv9:/common/packages/8.1.1/java/jdk1.6.0_38/jre/../lib/sparcv9
SHELL=/usr/bin/sh
Signal Handlers:
SIGSEGV: [libjvm.so+0x9b3120], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
SIGBUS: [libjvm.so+0x9b3120], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
SIGFPE: [libjvm.so+0x23f6b8], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
SIGPIPE: [libjvm.so+0x23f6b8], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
SIGXFSZ: [libjvm.so+0x23f6b8], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
SIGILL: [libjvm.so+0x23f6b8], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGUSR2: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGQUIT: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGHUP: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGINT: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGTERM: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIG39: [libjvm.so+0x86c2c8], sa_mask[0]=0x00000000, sa_flags=0x00000008
SIG40: [libjvm.so+0x23f6b8], sa_mask[0]=0xffbffeff, sa_flags=0x0000000c
--------------- S Y S T E M ---------------
OS: Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC
Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
Assembled 17 January 2013
uname:SunOS 5.10 Generic_150400-11 sun4v (T2 libthread)
rlimit: STACK 8192k, CORE infinity, NOFILE 65536, AS infinity
load average:1.28 1.30 1.30
CPU:total 16 has_v8, has_v9, popc, has_vis1, has_vis2, has_blk_init, is_ultra3, is_sun4v, is_niagara, is_niagara_plus
Memory: 8k page, physical 16777216k(8945944k free)
vm_info: Java HotSpot(TM) 64-Bit Server VM (20.13-b02) for solaris-sparc JRE (1.6.0_38-b05), built on Nov 14 2012 00:50:51 by "" with Workshop 5.8
time: Tue Nov 4 14:30:01 2014
elapsed time: 0 seconds
下面的ulimit結果
bash-3.2$ ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 10
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 2048
virtual memory (kbytes, -v) unlimited
Java版本:
bash-3.2$ java -version -d64
java version "1.6.0_38"
Java(TM) SE Runtime Environment (build 1.6.0_38-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
我已檢查與此相關的其他職位,但仍然在我的情況下無法正常工作。任何建議我需要做什麼?
有很多事情可以對它有所貢獻,但內存泄漏是最有可能的罪魁禍首。嘗試減少你的線索,然後看看你是否仍然有錯誤。內存泄漏隨着時間的推移而增加,因此線程越少意味着您的泄漏速度越慢。相反,更多的線程意味着你將更快地到達那裏,這意味着確定它是否是內存泄漏可能更容易(修復它是另一回事)。 – 2014-11-04 14:19:25
您的MaxPermSize設置太高,啓動您的Java程序時,物理內存是多少? (自由)。 – nomoa 2014-11-04 14:20:45
@MarshallTigerus這就是我所做的。我嘗試從最低內存直到4G內存。但仍然有同樣的錯誤。 – Sh4m 2014-11-04 14:38:19