语 法:ulimit [-aHS][-c <core文件上限>][-d <数据节区大小>][-f <文件大 小>][-m <内存大小>][-n <文件数目>][-p <缓冲区大小>][-s <堆叠大 小>][-t <CPU时间>][-u <程序数目>][-v <虚拟内存大小>]
补充说明:ulimit为shell内建指令,可用来控制shell执行程序的资源。
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at java.lang.ref.Reference.<clinit>(Reference.java:162)
内容: # # There is insufficient memory for the Java Runtime Environment to continue. # Cannot create GC thread. Out of system resources. # 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 (gcTaskThread.cpp:46), pid=25470, tid=140583204763392 # # JRE version: (7.0_76-b13) (build ) # Java VM: Java HotSpot(TM) 64-Bit Server VM (24.76-b04 mixed mode linux-amd64 compressed oops) # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # --------------- T H R E A D --------------- Current thread (0x00007fdc0c008800): JavaThread "Unknown thread" [_thread_in_vm, id=25471, stack(0x00007fdc13eb3000,0x00007fdc13fb4000)] Stack: [0x00007fdc13eb3000,0x00007fdc13fb4000], sp=0x00007fdc13fb2540, free space=1021k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x9a32ba] VMError::report_and_die()+0x2ea V [libjvm.so+0x497f7b] report_vm_out_of_memory(char const*, int, unsigned long, char const*)+0x9b V [libjvm.so+0x5584ba] GCTaskThread::GCTaskThread(GCTaskManager*, unsigned int, unsigned int)+0x11a V [libjvm.so+0x557a38] GCTaskManager::initialize()+0x2b8 V [libjvm.so+0x8417f8] ParallelScavengeHeap::initialize()+0x6f8 V [libjvm.so+0x97518a] Universe::initialize_heap()+0xca V [libjvm.so+0x976359] universe_init()+0x79 V [libjvm.so+0x5b1d25] init_globals()+0x65 V [libjvm.so+0x95dc4d] Threads::create_vm(JavaVMInitArgs*, bool*)+0x1ed V [libjvm.so+0x639fe4] JNI_CreateJavaVM+0x74 C [libjli.so+0x2f8e] JavaMain+0x9e --------------- P R O C E S S --------------- Java Threads: ( => current thread ) Other Threads: =>0x00007fdc0c008800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=25471, stack(0x00007fdc13eb3000,0x00007fdc13fb4000)] VM state:not at safepoint (not fully initialized) VM Mutex/Monitor currently owned by a thread: None GC Heap History (0 events): No events Deoptimization events (0 events): No events Internal exceptions (0 events): No events Events (0 events): No events Dynamic libraries: 00400000-00401000 r-xp 00000000 08:02 9961723 /usr/local/jdk1.7.0_76/bin/jstat 00600000-00601000 rw-p 00000000 08:02 9961723 /usr/local/jdk1.7.0_76/bin/jstat 00ef2000-00f13000 rw-p 00000000 00:00 0 [heap] 80000000-81500000 rw-p 00000000 00:00 0 81500000-85200000 rw-p 00000000 00:00 0 85200000-85780000 rw-p 00000000 00:00 0 85780000-581b00000 rw-p 00000000 00:00 0 581b00000-581f00000 rw-p 00000000 00:00 0 581f00000-800000000 rw-p 00000000 00:00 0 3d56400000-3d56420000 r-xp 00000000 08:02 3932555 /lib64/ld-2.12.so 3d5661f000-3d56620000 r--p 0001f000 08:02 3932555 /lib64/ld-2.12.so 3d56620000-3d56621000 rw-p 00020000 08:02 3932555 /lib64/ld-2.12.so 3d56621000-3d56622000 rw-p 00000000 00:00 0 3d56800000-3d56802000 r-xp 00000000 08:02 3932558 /lib64/libdl-2.12.so 3d56802000-3d56a02000 ---p 00002000 08:02 3932558 /lib64/libdl-2.12.so 3d56a02000-3d56a03000 r--p 00002000 08:02 3932558 /lib64/libdl-2.12.so 3d56a03000-3d56a04000 rw-p 00003000 08:02 3932558 /lib64/libdl-2.12.so 3d56c00000-3d56d8b000 r-xp 00000000 08:02 3932556 /lib64/libc-2.12.so 3d56d8b000-3d56f8a000 ---p 0018b000 08:02 3932556 /lib64/libc-2.12.so 3d56f8a000-3d56f8e000 r--p 0018a000 08:02 3932556 /lib64/libc-2.12.so 3d56f8e000-3d56f8f000 rw-p 0018e000 08:02 3932556 /lib64/libc-2.12.so 3d56f8f000-3d56f94000 rw-p 00000000 00:00 0 3d57000000-3d57017000 r-xp 00000000 08:02 3932563 /lib64/libpthread-2.12.so 3d57017000-3d57217000 ---p 00017000 08:02 3932563 /lib64/libpthread-2.12.so 3d57217000-3d57218000 r--p 00017000 08:02 3932563 /lib64/libpthread-2.12.so 3d57218000-3d57219000 rw-p 00018000 08:02 3932563 /lib64/libpthread-2.12.so 3d57219000-3d5721d000 rw-p 00000000 00:00 0 3d57400000-3d57407000 r-xp 00000000 08:02 3932564 /lib64/librt-2.12.so 3d57407000-3d57606000 ---p 00007000 08:02 3932564 /lib64/librt-2.12.so 3d57606000-3d57607000 r--p 00006000 08:02 3932564 /lib64/librt-2.12.so 3d57607000-3d57608000 rw-p 00007000 08:02 3932564 /lib64/librt-2.12.so 3d57800000-3d57883000 r-xp 00000000 08:02 3932279 /lib64/libm-2.12.so 3d57883000-3d57a82000 ---p 00083000 08:02 3932279 /lib64/libm-2.12.so 3d57a82000-3d57a83000 r--p 00082000 08:02 3932279 /lib64/libm-2.12.so 3d57a83000-3d57a84000 rw-p 00083000 08:02 3932279 /lib64/libm-2.12.so 7fdc033ac000-7fdc035f4000 rw-p 00000000 00:00 0 7fdc035f4000-7fdc035f5000 ---p 00000000 00:00 0 7fdc035f5000-7fdc036f5000 rw-p 00000000 00:00 0 7fdc036f5000-7fdc036f6000 ---p 00000000 00:00 0 7fdc036f6000-7fdc037f6000 rw-p 00000000 00:00 0 7fdc037f6000-7fdc037f7000 ---p 00000000 00:00 0 7fdc037f7000-7fdc038f7000 rw-p 00000000 00:00 0 7fdc038f7000-7fdc038f8000 ---p 00000000 00:00 0 7fdc038f8000-7fdc039f8000 rw-p 00000000 00:00 0 7fdc039f8000-7fdc039f9000 ---p 00000000 00:00 0 7fdc039f9000-7fdc03af9000 rw-p 00000000 00:00 0 7fdc03af9000-7fdc03afa000 ---p 00000000 00:00 0 7fdc03afa000-7fdc03bfa000 rw-p 00000000 00:00 0 7fdc03bfa000-7fdc03bfb000 ---p 00000000 00:00 0 7fdc03bfb000-7fdc03cfb000 rw-p 00000000 00:00 0 7fdc03cfb000-7fdc03cfc000 ---p 00000000 00:00 0 7fdc03cfc000-7fdc03dfc000 rw-p 00000000 00:00 0 7fdc03dfc000-7fdc03dfd000 ---p 00000000 00:00 0 7fdc03dfd000-7fdc03efd000 rw-p 00000000 00:00 0 7fdc03efd000-7fdc03efe000 ---p 00000000 00:00 0 7fdc03efe000-7fdc03ffe000 rw-p 00000000 00:00 0 7fdc03ffe000-7fdc03fff000 ---p 00000000 00:00 0 7fdc03fff000-7fdc040ff000 rw-p 00000000 00:00 0 7fdc040ff000-7fdc04100000 ---p 00000000 00:00 0 7fdc04100000-7fdc04200000 rw-p 00000000 00:00 0 7fdc04200000-7fdc04201000 ---p 00000000 00:00 0 7fdc04201000-7fdc04301000 rw-p 00000000 00:00 0 7fdc04301000-7fdc04302000 ---p 00000000 00:00 0 7fdc04302000-7fdc04402000 rw-p 00000000 00:00 0 7fdc04402000-7fdc04403000 ---p 00000000 00:00 0 7fdc04403000-7fdc04503000 rw-p 00000000 00:00 0 7fdc04503000-7fdc04504000 ---p 00000000 00:00 0 7fdc04504000-7fdc04604000 rw-p 00000000 00:00 0 7fdc04604000-7fdc04605000 ---p 00000000 00:00 0 7fdc04605000-7fdc04705000 rw-p 00000000 00:00 0 7fdc04705000-7fdc04706000 ---p 00000000 00:00 0 7fdc04706000-7fdc04806000 rw-p 00000000 00:00 0 7fdc04806000-7fdc04807000 ---p 00000000 00:00 0 7fdc04807000-7fdc04907000 rw-p 00000000 00:00 0 7fdc04907000-7fdc04908000 ---p 00000000 00:00 0 7fdc04908000-7fdc04a08000 rw-p 00000000 00:00 0 7fdc04a08000-7fdc04a09000 ---p 00000000 00:00 0 7fdc04a09000-7fdc04b09000 rw-p 00000000 00:00 0 7fdc04b09000-7fdc04b0a000 ---p 00000000 00:00 0 7fdc04b0a000-7fdc04c0a000 rw-p 00000000 00:00 0 7fdc04c0a000-7fdc04c0b000 ---p 00000000 00:00 0 7fdc04c0b000-7fdc04d0b000 rw-p 00000000 00:00 0 7fdc04d0b000-7fdc04d0c000 ---p 00000000 00:00 0 7fdc04d0c000-7fdc04e0c000 rw-p 00000000 00:00 0 7fdc04e0c000-7fdc04e0d000 ---p 00000000 00:00 0 7fdc04e0d000-7fdc04f0d000 rw-p 00000000 00:00 0 7fdc04f0d000-7fdc04f0e000 ---p 00000000 00:00 0 7fdc04f0e000-7fdc0500e000 rw-p 00000000 00:00 0 7fdc0500e000-7fdc0500f000 ---p 00000000 00:00 0 7fdc0500f000-7fdc0510f000 rw-p 00000000 00:00 0 7fdc0510f000-7fdc05110000 ---p 00000000 00:00 0 7fdc05110000-7fdc05210000 rw-p 00000000 00:00 0 7fdc05210000-7fdc05211000 ---p 00000000 00:00 0 7fdc05211000-7fdc05311000 rw-p 00000000 00:00 0 7fdc05311000-7fdc05312000 ---p 00000000 00:00 0 7fdc05312000-7fdc05412000 rw-p 00000000 00:00 0 7fdc05412000-7fdc05413000 ---p 00000000 00:00 0 7fdc05413000-7fdc05513000 rw-p 00000000 00:00 0 7fdc05513000-7fdc05514000 ---p 00000000 00:00 0 7fdc05514000-7fdc05614000 rw-p 00000000 00:00 0 7fdc05614000-7fdc05615000 ---p 00000000 00:00 0 7fdc05615000-7fdc05715000 rw-p 00000000 00:00 0 7fdc05715000-7fdc05716000 ---p 00000000 00:00 0 7fdc05716000-7fdc05816000 rw-p 00000000 00:00 0 7fdc05816000-7fdc05817000 ---p 00000000 00:00 0 7fdc05817000-7fdc05917000 rw-p 00000000 00:00 0 7fdc05917000-7fdc05918000 ---p 00000000 00:00 0 7fdc05918000-7fdc05a18000 rw-p 00000000 00:00 0 7fdc05a18000-7fdc05a19000 ---p 00000000 00:00 0 7fdc05a19000-7fdc05b19000 rw-p 00000000 00:00 0 7fdc05b19000-7fdc05b1a000 ---p 00000000 00:00 0 7fdc05b1a000-7fdc05c1d000 rw-p 00000000 00:00 0 7fdc05c1d000-7fdc083ff000 rw-p 00000000 00:00 0 7fdc083ff000-7fdc0840a000 rw-p 00000000 00:00 0 7fdc0840a000-7fdc08428000 rw-p 00000000 00:00 0 7fdc08428000-7fdc0842b000 rw-p 00000000 00:00 0 7fdc0842b000-7fdc0ac0c000 rw-p 00000000 00:00 0 7fdc0ac0c000-7fdc0ac0f000 rw-p 00000000 00:00 0 7fdc0ac0f000-7fdc0bfff000 rw-p 00000000 00:00 0 7fdc0bfff000-7fdc0c000000 rw-p 00000000 00:00 0 7fdc0c000000-7fdc0c077000 rw-p 00000000 00:00 0 7fdc0c077000-7fdc10000000 ---p 00000000 00:00 0 7fdc1005b000-7fdc1005c000 ---p 00000000 00:00 0 7fdc1005c000-7fdc1015c000 rw-p 00000000 00:00 0 7fdc1015c000-7fdc1015d000 ---p 00000000 00:00 0 7fdc1015d000-7fdc1025d000 rw-p 00000000 00:00 0 7fdc1025d000-7fdc1025e000 ---p 00000000 00:00 0 7fdc1025e000-7fdc1035e000 rw-p 00000000 00:00 0 7fdc1035e000-7fdc1035f000 ---p 00000000 00:00 0 7fdc1035f000-7fdc1045f000 rw-p 00000000 00:00 0 7fdc1045f000-7fdc10460000 ---p 00000000 00:00 0 7fdc10460000-7fdc1056b000 rw-p 00000000 00:00 0 7fdc1056b000-7fdc10589000 rw-p 00000000 00:00 0 7fdc10589000-7fdc10593000 rw-p 00000000 00:00 0 7fdc10593000-7fdc10649000 rw-p 00000000 00:00 0 7fdc10649000-7fdc108b9000 rwxp 00000000 00:00 0 7fdc108b9000-7fdc13649000 rw-p 00000000 00:00 0 7fdc13649000-7fdc13663000 r-xp 00000000 08:02 9308536 /usr/local/jdk1.7.0_76/jre/lib/amd64/libzip.so 7fdc13663000-7fdc13863000 ---p 0001a000 08:02 9308536 /usr/local/jdk1.7.0_76/jre/lib/amd64/libzip.so 7fdc13863000-7fdc13864000 rw-p 0001a000 08:02 9308536 /usr/local/jdk1.7.0_76/jre/lib/amd64/libzip.so 7fdc13864000-7fdc13870000 r-xp 00000000 08:02 3932190 /lib64/libnss_files-2.12.so 7fdc13870000-7fdc13a70000 ---p 0000c000 08:02 3932190 /lib64/libnss_files-2.12.so 7fdc13a70000-7fdc13a71000 r--p 0000c000 08:02 3932190 /lib64/libnss_files-2.12.so 7fdc13a71000-7fdc13a72000 rw-p 0000d000 08:02 3932190 /lib64/libnss_files-2.12.so 7fdc13a72000-7fdc13a7a000 rw-s 00000000 08:02 2097165 /tmp/hsperfdata_bdcsc2/25470 7fdc13a7a000-7fdc13aa3000 r-xp 00000000 08:02 9308541 /usr/local/jdk1.7.0_76/jre/lib/amd64/libjava.so 7fdc13aa3000-7fdc13ca3000 ---p 00029000 08:02 9308541 /usr/local/jdk1.7.0_76/jre/lib/amd64/libjava.so 7fdc13ca3000-7fdc13ca5000 rw-p 00029000 08:02 9308541 /usr/local/jdk1.7.0_76/jre/lib/amd64/libjava.so 7fdc13ca5000-7fdc13cb2000 r-xp 00000000 08:02 9308528 /usr/local/jdk1.7.0_76/jre/lib/amd64/libverify.so 7fdc13cb2000-7fdc13eb1000 ---p 0000d000 08:02 9308528 /usr/local/jdk1.7.0_76/jre/lib/amd64/libverify.so 7fdc13eb1000-7fdc13eb3000 rw-p 0000c000 08:02 9308528 /usr/local/jdk1.7.0_76/jre/lib/amd64/libverify.so 7fdc13eb3000-7fdc13eb6000 ---p 00000000 00:00 0 7fdc13eb6000-7fdc13fb4000 rw-p 00000000 00:00 0 7fdc13fb4000-7fdc14b29000 r-xp 00000000 08:02 9308514 /usr/local/jdk1.7.0_76/jre/lib/amd64/server/libjvm.so 7fdc14b29000-7fdc14d29000 ---p 00b75000 08:02 9308514 /usr/local/jdk1.7.0_76/jre/lib/amd64/server/libjvm.so 7fdc14d29000-7fdc14ded000 rw-p 00b75000 08:02 9308514 /usr/local/jdk1.7.0_76/jre/lib/amd64/server/libjvm.so 7fdc14ded000-7fdc14e31000 rw-p 00000000 00:00 0 7fdc14e31000-7fdc14e47000 r-xp 00000000 08:02 9962479 /usr/local/jdk1.7.0_76/lib/amd64/jli/libjli.so 7fdc14e47000-7fdc15047000 ---p 00016000 08:02 9962479 /usr/local/jdk1.7.0_76/lib/amd64/jli/libjli.so 7fdc15047000-7fdc15048000 rw-p 00016000 08:02 9962479 /usr/local/jdk1.7.0_76/lib/amd64/jli/libjli.so 7fdc15048000-7fdc15049000 rw-p 00000000 00:00 0 7fdc1504d000-7fdc15050000 rw-p 00000000 00:00 0 7fdc15050000-7fdc15051000 r--p 00000000 00:00 0 7fdc15051000-7fdc15052000 rw-p 00000000 00:00 0 7fff8fa5b000-7fff8fa70000 rw-p 00000000 00:00 0 [stack] 7fff8fb79000-7fff8fb7a000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] VM Arguments: jvm_args: -Dapplication.home=/usr/local/jdk1.7.0_76 -Xms8m java_command: sun.tools.jstat.Jstat -gcutil 24156 1000 10 Launcher Type: SUN_STANDARD Environment Variables: JAVA_HOME=/usr/local/jdk1.7.0_76/ PATH=/data/flumecollector/hbase/hbase-0.98.8-hadoop2/bin:/data/flumecollector/hive/apache-hive-0.14.0-bin/bin:/data/flumecollector/hive/apache-hive-0.14.0-bin/hcatalog/ bin:/data/flumecollector/hive/apache-hive-0.14.0-bin/hcatalog/sbin:/data/flumecollector/hadoop/hadoop-2.6.0/bin:/data/flumecollector/hadoop/hadoop-2.6.0/sbin:/usr/local /jdk1.7.0_76//bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/bdcsc2/bin/bin SHELL=/bin/bash Signal Handlers: SIGSEGV: [libjvm.so+0x9a3bd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGBUS: [libjvm.so+0x9a3bd0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGFPE: [libjvm.so+0x81cb60], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGPIPE: [libjvm.so+0x81cb60], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGXFSZ: [libjvm.so+0x81cb60], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGILL: [libjvm.so+0x81cb60], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 SIGUSR2: [libjvm.so+0x81e360], sa_mask[0]=0x00000000, sa_flags=0x10000004 SIGHUP: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 SIGINT: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 SIGTERM: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 SIGQUIT: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000 --------------- S Y S T E M ---------------
学习ulimit命令的用法。
功能说明:控制shell程序的资源。
语 法:ulimit [-aHS][-c <core文件上限>][-d <数据节区大小>][-f <文件大 小>][-m <内存大小>][-n <文件数目>][-p <缓冲区大小>][-s <堆叠大 小>][-t <CPU时间>][-u <程序数目>][-v <虚拟内存大小>]
补充说明:ulimit为shell内建指令,可用来控制shell执行程序的资源。
参 数:
-a 显示目前资源限制的设定。
-c <core文件上限> 设定core文件的最大值,单位为区块。
-d <数据节区大小> 程序数据节区的最大值,单位为KB。
-f <文件大小> shell所能建立的最大文件,单位为区块。
-H 设定资源的硬性限制,也就是管理员所设下的限制。
-m <内存大小> 指定可使用内存的上限,单位为KB。
-n <文件数目> 指定同一时间最多可开启的文件数。
-p <缓冲区大小> 指定管道缓冲区的大小,单位512字节。
-s <堆叠大小> 指定堆叠的上限,单位为KB。
-S 设定资源的弹性限制。
-t <CPU时间> 指定CPU使用时间的上限,单位为秒。
-u <程序数目> 用户最多可开启的程序数目。
-v <虚拟内存大小> 指定可使用的虚拟内存上限,单位为KB。
ulimit -a 用来显示当前的各种用户进程限制。
Linux对于每个用户,系统限制其最大进程数。为提高性能,可以根据设备资源情况,设置各linux 用户的最大进程数。
例如,把某linux用户的最大进程数设为10000个:
ulimit -u 10000
对于需要做许多 socket 连接并使它们处于打开状态的 Java 应用程序而言,
最好通过使用 ulimit -n xx 修改每个进程可打开的文件数,缺省值是 1024。
ulimit -n 4096 将每个进程可以打开的文件数目加大到4096,缺省为1024
其他建议设置成无限制(unlimited)的一些重要设置是:
数据段长度:ulimit -d unlimited
最大内存大小:ulimit -m unlimited
堆栈大小:ulimit -s unlimited
CPU 时间:ulimit -t unlimited
虚拟内存:ulimit -v unlimited
有时服务器需要调整ulimit的stack size 参数调整为unlimited 无限,使用ulimit -s unlimited时只能在当时的shell见效,重开一个shell则失效。
解决方法:
在/etc/profile 的最后面添加ulimit -s unlimited。
然后:
# source /etc/profile
使修改即时生效。
可能的问题:
如果碰到类似的错误提示
ulimit: max user processes: cannot modify limit: 不允许的操作
ulimit: open files: cannot modify limit: 不允许的操作
以上操作对root用户是不会提示这样的限制信息的,只对普通用户有影响,原因何在?
大家可以去研究下文件:/etc/security/limits.conf。
说明:
linux对用户有默认的ulimit限制,而这个文件可以配置用户的硬配置和软配置,硬配置是个上限。
超出上限的修改就会出“不允许的操作”这样的错误。
可以在limits.conf文件最后添加相关内容,如下图:
即限制任意用户的最大线程数和文件数为10240。