我有一个带4GB RAM的ubuntu 14.04系统,x86_64 3.13.0-48通用内核和openjdk-7.
我的记忆用法如下:
# free -h
total used free shared buffers cached
Mem: 3.7G 3.6G 127M 988M 44M 3.3G
-/+ buffers/cache: 232M 3.4G
Swap: 0B 0B 0B
因此,有足够的内存用作磁盘缓存,当任何应用程序需要时,应该刷新和释放(AFAIK).
所以,我尝试运行java:
# java -Xms32m -Xmx512m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
只运行java -version会返回相同的结果.当有3GB的缓存内存时,为什么java不能运行?我在同一台机器上运行Postresql,但它的shared_buffers设置为940MB.
编辑:
我强制刷新磁盘缓存 – 仍然是相同的结果:
# free -h
total used free shared buffers cached
Mem: 3.7G 1.9G 1.8G 988M 35M 1.7G
-/+ buffers/cache: 196M 3.5G
Swap: 0B 0B 0B
# java -Xms32m -Xmx512m -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
EDIT2:
这是ulimit -a:
# ulimit -a
core file size (blocks,-c) 0
data seg size (kbytes,-d) unlimited
scheduling priority (-e) 0
file size (blocks,-f) unlimited
pending signals (-i) 30034
max locked memory (kbytes,-l) 64
max memory size (kbytes,-m) unlimited
open files (-n) 1024
pipe size (512 bytes,-p) 8
POSIX message queues (bytes,-q) 819200
real-time priority (-r) 0
stack size (kbytes,-s) 32000
cpu time (seconds,-t) unlimited
max user processes (-u) 30034
virtual memory (kbytes,-v) unlimited
file locks (-x) unlimited
EDIT3:
我完全没有得到它:我试图添加4GB交换,结果是它工作,虽然没有使用交换:
# free -h
total used free shared buffers cached
Mem: 3.7G 3.5G 196M 988M 44M 3.2G
-/+ buffers/cache: 239M 3.4G
Swap: 4.0G 0B 4.0G
# java -version
java version "1.6.0_36"
OpenJDK Runtime Environment (IcedTea6 1.13.8) (6b36-1.13.8-0ubuntu1~14.04)
OpenJDK 64-Bit Server VM (build 23.25-b01,mixed mode)
最佳答案
你需要运行一些东西.
原文链接:https://www.f2er.com/linux/440785.html喜欢
java -Xmx1024m -cp /path/to/jar/ com.project.Start