我有以下问题:
$ java -jar program.jar
Error occurred during initialization of VM
Could not reserve enough space for code cache
Run Code Online (Sandbox Code Playgroud)
系统看到的内存量似乎已足够:
$ free -m
total used free shared buffers cached
Mem: 5959 640 5318 0 0 390
-/+ buffers/cache: 249 5710
Swap: 4099 0 4099
Run Code Online (Sandbox Code Playgroud)
我尝试将堆设置降低到16mb,但它没有帮助:
$ java -Xmx16m -Xms16m -jar program.jar
Error occurred during initialization of VM
Could not reserve enough space for code cache
Run Code Online (Sandbox Code Playgroud)
有什么不对?我该怎么调试呢?
编辑: 忘记包含版本 - 我使用Sun Java 7u15,64位.我实际上无法让它显示版本字符串,因为"java -version"失败并出现相同的错误.
此外,由于某种原因,如果我使用OpenJDK 6u27,它会启动 - 但由于应用程序需要java 7,它不起作用.
似乎我的java在Gentoo Hardened Linux上运行,并且内核启用了PaX.要禁用pax内存控制,我使用以下命令:
paxctl -c -m /path/to/your/java/bin/java
Run Code Online (Sandbox Code Playgroud)
在那之后,一切都很顺利.