这是我的脚本(我只是想尝试解决一个更大的问题):
#!/bin/bash
JAVA_OPTS="-Xms64m -Xmx64m"
for i in 1 2 3 4 5 6 7 8 9 10
do
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java -version &
done
简而言之,我试图同时启动 10 个 java 进程。服务器有 512Mb 的 RAM 和 4Gb 的交换空间。对于每个 64Mb 的十个进程来说,这应该绰绰有余了。但是,这是我在其中两个的输出中看到的:
Error occurred during initialization of VM
Could not reserve enough space for the card marking array
Error occurred during initialization of VM
Could not reserve enough space for code cache
为什么会这样?如何解决?
崩溃的进程以此开始创建文件:
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 160088 bytes for HashtableBucket in /build/buildd/openjdk-7-7u21-2.3.9/build/openjdk/hotspot/src/share/vm/utilities/hashtable.inline.hpp
# 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=
以下哪一项是我的情况?