Could not allocate enough heap space to Java

半腔热情 提交于 2020-01-21 05:17:40

问题


We have an application which was running fine for one year. It is a web application, running under Tomcat 5.5 + JDK 1.5 under Microsoft Cluster on Windows Server 2003 Enterprise Edition Service Pack 2. The server has 11Gb of RAM (I know that it is useless!) with the following description "Physical Address Extension": I don't know what that means.

The Tomcat service is configured with the following parameters: -Xmx1024m -Xms128m

Since last week, the service doesn't want to start anymore and stops with the following error message: "Could not allocate enough heap space".

We tried several tests:

  • java -Xmx1024m -version => Failed
  • java -Xmx758m -version => Failed
  • java -Xmx512m -version => Passed

So we can use less memory for the maximum heap size, but it is not an acceptable workaround because the number of users will increase in few months and we need to set the maximum heap size to 1024Mb.

Also I don't understand why it worked fine and then suddenly it stopped working! It seems that the OS is now unable to allocate contiguous memory, or something else (page file size, user memory allocation, ...)

It's quite difficult to know if something changed (OS patch, configuration, ...) because the web application is running on the customer server and we don't have access to it.


回答1:


Java requires continous memory. On 32-bit OSes this limits you to between 1.2 and 1.4 GB on Windows. However if your memory is fragmented due to other programs which are running, you might get a much smaller region of memory.

You won't get this problem with a 64-bit OS and you can even allocate far more memory to the jVM as well (if you use a 64-bit JVM)




回答2:


I've got some news about my problem.

This seems to be due to a Windows security update ! This Microsoft security update prevents java applications to allocate a large amount of contiguous memory...

More information here: http://support.microsoft.com/kb/971812

We will check if the patch solves this problem. Stay tuned




回答3:


Also I don't understand why it worked fine and suddenly it stopped to work ! It seems that the OS is now unable to allocate contiguous memory, or something else (page file size, user memory allocation, ...)

It's quite difficult to know if something changed (OS patch, configuration, ...) because the web application is running on the customer server and we have no access to it.

Well, you should check how much memory is available and if it's not enough, you should check what is consuming that much memory.

Other than that, you'd have to talk to your customer and find out if they did changes to the server and if so, what they did change.

Without knowing more it's really hard up to impossible to give any qualified advice on why you can't allocate more memory.




回答4:


It probably means the OS can not allocate enough continuous memory. Do you still have the problem after OS restart? Does the system report it has 11 Gb of RAM? Windows's implementation of PAE is not the best one, so it could cause problems. Try updating to a newer JDK, if that fails, you'd need a 64-bit machine.



来源:https://stackoverflow.com/questions/5788356/could-not-allocate-enough-heap-space-to-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!