gpt4 book ai didi

java - 在全局范围内限制 Play 框架的 Java 堆空间

转载 作者:IT老高 更新时间:2023-10-28 21:00:00 25 4
gpt4 key购买 nike

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

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堆空间:

jvm.memory=-Xmx256M -Xms256M

通过该设置,我可以运行游戏测试、游戏运行等......

但我不能跑:

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 堆空间?

更新:以下也不起作用:

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,

雷内

最佳答案

Play 似乎没有为依赖项甚至测试命令获取 jvm.memory 设置。强制它使用特定 JVM 设置的一种方法是使用 _JAVA_OPTIONS。

例如:

export _JAVA_OPTIONS="-Xms800m -Xmx1500m -XX:PermSize=64m -XX:MaxPermSize=256m"
play test

play deps

你应该看到

~        _            _ 
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.3, http://www.playframework.org
~ framework ID is test
~
~ Running in test mode
~ Ctrl+C to stop
~
Picked up _JAVA_OPTIONS: -Xms800m -Xmx1500m -XX:PermSize=64m -XX:MaxPermSize=256m
Listening for transport dt_socket at address: 8000

请注意,这会将这些设置应用于在设置了 _JAVA_OPTIONS 的终端上运行的所有 java 程序。

关于java - 在全局范围内限制 Play 框架的 Java 堆空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6763453/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com