我知道这个问题一直存在很长时间, 但是所有解决方案都对我没有成功
Maven throws "java.lang.OutOfMemoryError"
How to deal with "java.lang.OutOfMemoryError: Java heap space" error?
尽管我尝试了以上两种解决方案,还尝试了其他建议的选项 其他答案仍然导致我遇到以下错误
17-Dec-2018 11:36:54 Exception in thread "ForkJoinPool.commonPool-worker-5" java.lang.OutOfMemoryError: unable to create new native thread
17-Dec-2018 11:36:54 at java.lang.Thread.start0(Native Method)
17-Dec-2018 11:36:54 at java.lang.Thread.start(Thread.java:717)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinPool.createWorker(ForkJoinPool.java:1486)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinPool.tryAddWorker(ForkJoinPool.java:1517)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinPool.deregisterWorker(ForkJoinPool.java:1609)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:167)
17-Dec-2018 11:36:54 Exception in thread "ForkJoinPool.commonPool-worker-0" java.lang.OutOfMemoryError: unable to create new native thread
17-Dec-2018 11:36:54 at java.lang.Thread.start0(Native Method)
17-Dec-2018 11:36:54 at java.lang.Thread.start(Thread.java:717)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinPool.createWorker(ForkJoinPool.java:1486)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinPool.tryAddWorker(ForkJoinPool.java:1517)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinPool.deregisterWorker(ForkJoinPool.java:1609)
17-Dec-2018 11:36:54 at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:167)
说清楚点
我已经使用sure-fire来运行testng测试并相应地生成报告...所以我首先应用了添加argline的方法,但没有帮助。然后我尝试添加MAVEN_OPTS并增加了从256到1024范围的值,但最终没有添加JAVA_TOOL_OPTIONS,即使我尝试了多个值来指定
,它仍然不起作用还有其他选择可以尝试解决问题吗?
不要标记此重复项...我需要比现有的更好的解决方案。
已编辑
使用命令lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 2
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 61
Model name: Intel Core Processor (Broadwell)
Stepping: 2
CPU MHz: 2197.454
BogoMIPS: 4394.90
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
NUMA node0 CPU(s): 0-7
使用uname -a
Linux pt-00-00 3.10.0-327.4.5.el7.x86_64 #1 SMP Thu Jan 21 04:10:29 EST 2016 x86_64 x86_64 x86_64 GNU/Linux
cat /proc/meminfo
MemTotal: 24517356 kB
MemFree: 24048256 kB
MemAvailable: 24054212 kB
Buffers: 35556 kB
Cached: 142932 kB
SwapCached: 0 kB
Active: 81092 kB
Inactive: 144820 kB
Active(anon): 47652 kB
Inactive(anon): 24724 kB
Active(file): 33440 kB
Inactive(file): 120096 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 4193276 kB
SwapFree: 4193276 kB
Dirty: 8 kB
Writeback: 0 kB
AnonPages: 47688 kB
Mapped: 40864 kB
Shmem: 24896 kB
Slab: 55872 kB
SReclaimable: 27304 kB
SUnreclaim: 28568 kB
KernelStack: 5520 kB
PageTables: 4180 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 16451952 kB
Committed_AS: 238360 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 169716 kB
VmallocChunk: 34359564288 kB
HardwareCorrupted: 0 kB
AnonHugePages: 12288 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 63344 kB
DirectMap2M: 25102336 kB
vmstat -s
24517356 K total memory
234276 K used memory
81704 K active memory
145092 K inactive memory
24048760 K free memory
35656 K buffer memory
198664 K swap cache
4193276 K total swap
0 K used swap
4193276 K free swap
3630 non-nice user cpu ticks
24 nice user cpu ticks
6329 system cpu ticks
21548595 idle cpu ticks
1549 IO-wait cpu ticks
0 IRQ cpu ticks
16 softirq cpu ticks
25 stolen cpu ticks
142239 pages paged in
101165 pages paged out
0 pages swapped in
0 pages swapped out
1169647 interrupts
1713506 CPU context switches
1546461109 boot time
50951 forks
答案 0 :(得分:2)
您可以像这样配置maven-surefire-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>x.x.x</version>
<configuration>
<argLine>-Xmx2048m -XX:MaxPermSize=1024m</argLine>
</configuration>
</plugin>
设置JVM参数。