英文:
Error occurred during initialization of VM: Could not reserve enough space for code cache when executing jar file as regular user on Centos 7
问题
我有一台装有64GB内存(可用49GB)的Centos 7机器,在尝试以以下命令作为普通用户执行一个jar文件时出现了问题:
java -jar jarfile.jar
它返回以下错误信息:
VM初始化期间发生错误
<br>
无法为代码缓存保留足够的空间
然而,当我切换到root用户并执行相同的命令时,它成功运行。我已经确认执行jar文件的用户是文件的所有者,文件的权限设置为:
-rw-rw-r--
我还检查了机器上是否有足够的可用空间。
请问有谁可以提出可能导致这个问题的原因以及如何解决,以便jar文件能够作为普通用户成功执行?
谢谢
英文:
I have a Centos 7 machine with 64gb memory (49gb available) where I am experiencing an issue when trying to execute a jar file as a regular user with the following command:
java -jar jarfile.jar
It returns the error:
Error occurred during initialization of VM
<br>
Could not reserve enough space for code cache
However, when I switch to the root user and execute the same command, it runs successfully. I have checked that the user executing the jar file is the owner and the permissions of the file are set to:
-rw-rw-r--
I have also checked that there is enough space available on the machine.
Can anyone kindly suggest what could be causing this issue and how I can resolve it to enable the jar file to be executed successfully as a regular user?
Thanks
答案1
得分: 0
我在/etc/profile中进行了以下更新以解决问题:
LIMITUSER=$USER
if [ -e "/usr/bin/whoami" ]; then
LIMITUSER=`/usr/bin/whoami`
fi
if [ "$LIMITUSER" == "root" ]; then
ulimit -n 6144 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
elif [ "$LIMITUSER" == "uptime" ]; then
ulimit -n 1024 -u 2047 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
else
ulimit -n 6144 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
英文:
I updated /etc/profile with the below to resolve
LIMITUSER=$USER
if [ -e "/usr/bin/whoami" ]; then
LIMITUSER=`/usr/bin/whoami`
fi
if [ "$LIMITUSER" == "root" ]; then
ulimit -n 6144 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
elif [ "$LIMITUSER" == "uptime" ]; then
ulimit -n 1024 -u 2047 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
else
ulimit -n 6144 -u 14335 -m unlimited -d unlimited -s 8192 -c 1000000 -v unlimited 2>/dev/null
fi
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论