Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ubuntu上的Java内存不足,但存在大量缓存内存_Java_Linux_Ubuntu_Caching_Memory Management - Fatal编程技术网

ubuntu上的Java内存不足,但存在大量缓存内存

ubuntu上的Java内存不足,但存在大量缓存内存,java,linux,ubuntu,caching,memory-management,Java,Linux,Ubuntu,Caching,Memory Management,我得到了一个带有4GB内存、x86_64 3.13.0-48通用内核和openjdk-7的ubuntu 14.04系统 我的记忆使用情况如下: # free -h total used free shared buffers cached Mem: 3.7G 3.6G 127M 988M 44M 3.3G -/+ buffers/cache:

我得到了一个带有4GB内存、x86_64 3.13.0-48通用内核和openjdk-7的ubuntu 14.04系统

我的记忆使用情况如下:

# 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,但它的共享缓冲区设置为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.
编辑2:

这里是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
编辑3:

我完全不明白:我尝试添加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)

你需要做点什么


Java提供了正确的答案:您没有足够的可用内存来满足这个堆大小

您是否在这台机器上尝试了一个
top
,然后是Shift+M?你的机器上有很多缓冲的东西,这是真的

为什么不添加交换分区


此外,您可以在此处查看:

这不是java问题,而是linux问题,应该在其他网站(superuser.com或aksubuntu.com)上询问我,因为问题是系统的可用内存为何如此之低。是的,奇怪,请尝试
strace java-Xms32m-Xmx512m-version
,这样您就可以看到什么系统调用实际上失败了。
java -Xmx1024m -cp /path/to/jar/ com.project.Start