为播放框架全局限制Java堆空间 [英] Limit Java Heap Space for play framework globaly

查看:78
本文介绍了为播放框架全局限制Java堆空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常古老的linux系统并安装了java和play框架。当我运行java时,我得到:

I have a very old linux system and installed java and play framework. When I run java I get:

java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

所以我限制了application.conf中的java堆空间:

So I limited the java heap space in application.conf:

jvm.memory=-Xmx256M -Xms256M

使用该设置我可以运行游戏测试,玩游戏等....

With that setting I can run play test, play run etc....

但是我无法运行:

play dependencies 
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.1, http://www.playframework.org
~
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

是否有全局配置文件或环境变量,我可以限制播放框架的java堆空间全局?

Is there a global configuration file or environment variable where I can limit java heap space globaly for play framework?

更新:
此外,以下内容无效:

Update: Also the following is not working:

play dependencies -Xmx256M -Xms256M
~        _            _ 
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/   
~
~ play! 1.2.1, http://www.playframework.org
~
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

更新2

内存:

ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 1024
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 38912
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

限制:

cat /proc/meminfo 
MemTotal:      4139312 kB
MemFree:        332988 kB
Buffers:        105252 kB
Cached:        1705644 kB
SwapCached:          4 kB
Active:        2566216 kB
Inactive:       625032 kB
HighTotal:      786432 kB
HighFree:         1728 kB
LowTotal:      3352880 kB
LowFree:        331260 kB
SwapTotal:     4192956 kB
SwapFree:      4168224 kB
Dirty:             368 kB
Writeback:           0 kB
Mapped:        1672180 kB
Slab:           570864 kB
CommitLimit:   6262612 kB
Committed_AS:  4075144 kB
PageTables:      19884 kB
VmallocTotal:   303096 kB
VmallocUsed:     10400 kB
VmallocChunk:   292648 kB

BR,

Rene

推荐答案

在谷歌搜索后我发现这个讨论。问题是,我的Linux系统在openvz容器中运行:

After googling more around I found this discussion. The problem is, that my Linux System is running in an openvz container:

Java抱怨的原因是因为在启动时它看到机器有超过2 GB的RAM,所以它在服务器模式下启动,它尝试分配所有内存,然后失败,因为它在VPS内。

我可以通过更改/usr/java/jdk1.6.0_26/jre/lib/i386/jvm.cfg修复java启动问题:

I could fix the java startup problem by changing /usr/java/jdk1.6.0_26/jre/lib/i386/jvm.cfg from:

-client IF_SERVER_CLASS -server
-server KNOWN
-hotspot ALIASED_TO -client
-classic WARN
-native ERROR
-green ERROR

to:

#-client IF_SERVER_CLASS -server
-client KNOWN
-server KNOWN
-hotspot ALIASED_TO -client
-classic WARN
-native ERROR
-green ERROR

现在我可以运行任何播放命令。也许这有助于其他人遇到与基于容器的虚拟化相关的类似问题。

Now I can run any play command. Maybe this helps other people having similar problems related to container based virtualization.

BR,Rene

这篇关于为播放框架全局限制Java堆空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆