Add a comment

 

Re: JVM Lies: The OutOfMemory Myth

One sign that you may have a leak in native code is when the JVM's OS process memory footprint vastly outweighs the actual heap size. We had this problem with a J2EE web app a couple of years ago. As the load increased over the months we started experiencing OOMEs which forced our admins to restart the app servers several times during the day. As we were using WebSphere I used an API supplied with the IBM JVM that allows you to cause a heap dump (just heap info) and a core dump (heap, stack and native info) programmatically. I stuck this in a JSP which our admins could call via telnet regularly via scripts. This allowed me to take snapshots of the heap as the memory increased throughout the day (or at least until the next restart). In addition to this we turned on the verbose GC. From the verbose GC log we found that the heap was behaving normally, expanding, sweeping and compacting at regular intervals. We could see that at the time of the OOME the heap was consuming about 70MB whereas the OS process size was over 500MB. IBM's GUI tool for visualising the heap dump and verbose GC output confirmed our suspicions. The core dump is intended for IBM staff so we sent all our findings to them. IBM found that the leak was coming from native libraries in the Oracle OCI JDBC driver we were using to connect to our database. It turned out that we had been using a very early version of the Oracle 9 JDBC driver which had some known native leaks and other bugs. After upgrading the driver to the then latest one the problem was gone instantly. This is just another example of an OOME not necessarily meaning that the app is poorly written or that the heap is always to blame. Cheers, Steve.

Re: JVM Lies: The OutOfMemory Myth


Title
Body
HTML : b, strong, i, em, blockquote, br, p, pre, a href="", ul, ol, li, sub, sup
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).