Java需要启动多少内存?

Java需要启动多少内存?,java,ubuntu,memory-management,Java,Ubuntu,Memory Management,这是我的脚本(我只是想尝试解决一个更大的问题): 简而言之,我试图同时启动10个java进程。服务器有512Mb的RAM和4Gb的交换空间。这对于10个进程来说应该足够了,每个进程64Mb。然而,这是我在其中两个的输出中看到的: Error occurred during initialization of VM Could not reserve enough space for the card marking array Error occurred during initializati

这是我的脚本(我只是想尝试解决一个更大的问题):

简而言之,我试图同时启动10个java进程。服务器有512Mb的RAM和4Gb的交换空间。这对于10个进程来说应该足够了,每个进程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=

以下哪一项是我的情况?

Java保留了一些在启动时必须是物理内存(而不是交换)的内存,以便对VM进行内部管理。如果没有足够的物理内存,JVM将无法启动。

我不确定这一点,但我认为当启动JVM时,它会占用启动时args中给出的所有内存。因此,您需要640M…您的意思是4Gb的交换不被视为JVM的内存吗?
-Xmx
定义了最大堆大小-整个Java进程使用的内存比这还要多。您不认为4Gb的可用内存应该远小于4Gb吗?这是一个可配置的参数吗?你能给我一些解释这个的链接吗?@yegor256不,没有参数,我也没有找到任何关于这个的参考。但是有一些结构需要存储在内存中,但正如我所说的,我没有发现任何引用。
# 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=