Java失败并显示“无法为代码缓存保留足够的空间". [英] Java fails with "Could not reserve enough space for code cache"
问题描述
我有以下问题:
$ java -jar program.jar
Error occurred during initialization of VM
Could not reserve enough space for code cache
系统看到的内存量似乎足够:
The amount of memory that is seen by the system seems sufficient:
$ free -m
total used free shared buffers cached
Mem: 5959 640 5318 0 0 390
-/+ buffers/cache: 249 5710
Swap: 4099 0 4099
我尝试将堆设置降低到16mb,但这没有帮助:
I tried lowering heap settings as low as 16mb, but it didn't help:
$ java -Xmx16m -Xms16m -jar program.jar
Error occurred during initialization of VM
Could not reserve enough space for code cache
有什么问题吗?我该如何调试?
What can be wrong? How can I debug this?
忘记包含版本-我使用的是64位Sun Java 7u15.我实际上无法显示版本字符串,因为"java -version"由于相同的错误而失败.
Forgot to include version - I use Sun Java 7u15, 64 bit. I actually can't get it to display a version string, because "java -version" fails with the same error.
此外,由于某种原因,如果我使用OpenJDK 6u27,它会启动-但由于该应用程序期望使用Java 7,因此它不起作用.
Also, for some reason, if I use OpenJDK 6u27, it starts up - but since the app expects java 7, it doesn't work.
推荐答案
似乎我的Java运行在 PaX .要禁用pax内存控制,我使用了以下命令:
Seems that my java was running on Gentoo Hardened Linux, and kernel had PaX enabled. To disable pax memory control, I used the following command:
paxctl -c -m /path/to/your/java/bin/java
那之后,一切都变得顺利了.
After that, everything was smooth.
这篇关于Java失败并显示“无法为代码缓存保留足够的空间".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!