9 Replies Latest reply: Mar 6, 2014 8:48 AM by jwenting RSS





      I am a DBA,new to Java.


      i got  call from application team about outof memory.Please check the below one.I couldn't undetstand it.It's related to DB side or application server.

      If it's application server,where i need to check the log


      org.springframework.transaction.TransactionSystemException: UOWManager transaction processing failed;

      nested exception is com.ibm.wsspi.uow.UOWException:

      java.lang.OutOfMemoryError at org.springframework.transaction.jta.WebSphereUowTransactionManager.

      execute(WebSphereUowTransactionManager.java:288) at org.springframework.transaction.interceptor.TransactionInterceptor.

      invoke(TransactionInterceptor.java:127) at org.springframework.aop.framework.ReflectiveMethodInvocation.

      proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.



      Any suggestions



        • 1. Re: OutOfMemoryError

          Hi. It is related to the application server. There can be a number of reasons for the OutOfMemoryError. There may be a file called javacore.<bunch of numbers>.txt in the server installation directory that you can look into. If the application runs in a WebSphere server, you may also find heap dumps automatically generated there.


          Do take a look at 2 solution of  java.lang.OutOfMemoryError in Java under the "Tools to investigate and fix OutOfMemoryError in Java" section for tools to help you with the investigation. You'd want to first find out more what type of OutOfMemoryError it is (e.g., heap space (most common), permgen, thread) before looking for the solution for this error, and so you'd want to skip the earlier sections on the web page.

          • 2. Re: OutOfMemoryError

            One thing to note is that the code that throws the exception is not necessarily the cause of the problem; it is only the point in the application where the resources ran out. Its really important to use a profiler to see where all the memory is going.

            • 3. Re: OutOfMemoryError

              I wholeheartedly agree with you, gimbal2. There have been a few times where OutOfMemoryError problems ended on my lap just because the stack trace shows code from the application I'm responsible for. Like the error line in the original post,

              java.lang.OutOfMemoryError at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:288)

              this only means that OutOfMemoryError occurred when this line of code is being executed. It doesn't mean that code in this area is definitely the cause of the problem. The cause may lie elsewhere in the application, or in someone else's application running in the same application server, taking up all available heap space (or permgen space, or threads, etc.) such that when the above line of code executes requiring some resources, the JVM has ran out of it. In other words, no one really knows where the problem lies until the application is profiled, or at least heap dumps at several points in time (if it is due to running out of heap space) are inspected with an analyser.

              • 4. Re: OutOfMemoryError

                OutOfMemoryError in Java is one problem which is more due to system's limitation (memory) rather than due to programming mistakes in most cases though in certain cases you could have memory leak which causing OutOfMemoryError.


                There are mainly two types of OutOfMemoryError in Java:

                1) Java.lang.OutOfMemoryError: Java heap space
                2) Java.lang.OutOfMemoryError: PermGen space

                How to solve java.lang.OutOfMemoryError: Java heap space

                • Easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError. This is my preferred solution when I get OutOfMemoryError in Eclipse, Maven or ANT while building project because based upon size of project you can easily ran out of Memory.here is an example of increasing maximum heap size of JVM, Also its better to keep -Xmx to -Xms ration either 1:1 or 1:1.5 if you are setting heap size in your java application

                                                export JVM_ARGS="-Xms1024m -Xmx1024m"

                • Second way to resolve OutOfMemoryError in Java is rather hard and  comes when you don't have much memory and even after increase maximum heap size you are still getting java.lang.OutOfMemoryError, in this case you probably want to profile your application and look for any memory leak. You can use Eclipse Memory Analyzer to examine your heap dump or you can use any profiler like Netbeans or JProbe. This is tough solution and requires some time to analyze and find memory leaks.


                How to solve java.lang.OutOfMemoryError: PermGen space
                Permanent generation of heap is used to store String pool and various Meta data required by JVM related to Class, method and other java primitives. Since in most of JVM default size of Perm Space is around "64MB" you can easily ran out of memory if you have too many classes or huge number of Strings in your project. Important point to remember is that it doesn't depends on –Xmx value so no matter how big your total heap size you can ran OutOfMemory in perm space. Good think is you can specify size of permanent generation using JVM options "-XX:PermSize" and  "-XX:MaxPermSize" based on your project need.

                As explained in above paragraph this OutOfMemory error in java comes when Permanent generation of heap filled up. To fix this OutOfMemoryError in Java you need to increase heap size of Perm space by using JVM option   "-XX:MaxPermSize". You can also specify initial size of Perm space by using    "-XX:PermSize" and keeping both initial and maximum Perm Space you can prevent some full garbage collection which may occur when Perm Space gets re-sized. Here is how you can specify initial and maximu Perm size in Java:

                                                export JVM_ARGS="-XX:PermSize=64M -XX:MaxPermSize=256m"


                Some time java.lang.OutOfMemoryError  in Java gets tricky and on those cases profiling remain ultimate solution.Though you have freedom to increase heap size in java, it’s recommended that to follow memory management practices while coding and setting null to any unused references.


                Thanks ,


                • 5. Re: OutOfMemoryError

                  Amrit, there are quite a few types of OutOfMemoryError (see Understanding the OutOfMemoryError | Java Code Geeks), and I have personally worked on 4:

                  1. java.lang.OutOfMemoryError: Java heap space
                  2. java.lang.OutOfMemoryError: Perm Space
                  3. java.lang.OutOfMemoryError: unable to create new native thread
                  4. java.lang.OutOfMemoryError: Out of swap space

                  I agree that the "Java heap space" type is the most common, but I've learned enough not to assume anything until I know which type it is. There is in fact 1 type where you can actually alleviate it by reducing the max heap size. To start adjusting the max heap size and/or perm gen size without first knowing if they need adjustment is practically doing something hoping that you'll get lucky. Therefore, I stand by my previous suggestion, "You'd want to first find out more what type of OutOfMemoryError it is (e.g., heap space (most common), permgen, thread) before looking for the solution for this error."



                  setting null to any unused references

                  is most of the time unnecessary in Java. References held by variables are automatically dropped when variables go out of scope. I wouldn't recommend this as a general practice as it increases code clutter.


                  Having said that, if the OutOfMemoryError turns out to be due to insufficient heap space or perm gen space, then your reply above for these types of errors will come in handy!

                  • 6. Re: OutOfMemoryError

                    Manual nulling is nowadays also NotAGoodIdea as it hinders the garbage collection efficiency. You need to have a little faith in the JVM to do its job properly, which it will if you just leave it alone.


                    But if you have a reference to a variable which translates into a huge pile of memory being claimed and you don't need it anymore, then a manual null can be an effective way to free up memory just a little sooner in a complicated piece of code which really needs it.

                    • 7. Re: OutOfMemoryError

                      running out of permgen space mostly happens when doing a lot of String externilization, which happens with some parser APIs (some versions of Eclipse are notorious for it, especially in their JSP editors).


                      Seeing that he's getting the error in code having to do with JTA, my initial suspicion would be running out of native threads due to an undue number of open database or network connections.

                      And that's mostly caused by sloppy connection handling code inside of an application (I seriously doubt WebSphere would be that sloppy, but whatever's running on top of it...).

                      • 8. Re: OutOfMemoryError

                        Yeah or web application redeployments tend to also be a major source. I spotted an interesting thread about that on Stackoverflow today:


                        java - Memory leak in web-app, tomcat+hibernate+Guice - Stack Overflow




                        "You can try adding these Java options:

                        -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

                        This enables garbage collection in PermGen space (off by default) and allows the GC to unload classes."

                        • 9. Re: OutOfMemoryError

                          probably the same reason, extensive XML parsing causing overload of permgen space.