我有一个 Java 程序可以在具有 2GB 物理内存和 2GB 交换空间的 Solaris 10 X86 上运行。
该程序在 64 位 Linux 下运行良好,仅消耗约 450MB 内存。
然而,当它在 Solaris 中运行时,它总是报告 OutOfMemoryError,我注意到在错误发生之前,它试图使用 > 4GB 的虚拟内存,这在 32 位系统上绝对不可能。
那么为什么 JVM 会尝试使用那么多虚拟内存呢?有没有办法告诉JVM不要使用那么多虚拟内存?
谢谢你。
编辑:
谢谢大家的意见!这是完整的错误消息:
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
# 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 (allocation.cpp:211), pid=1052, tid=16
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Server VM (20.1-b02 mixed mode solaris-x86 )
--------------- T H R E A D ---------------
Current thread (0x081a3400): JavaThread "C2 CompilerThread1" daemon