6 Replies Latest reply on Aug 19, 2013 12:27 AM by rm0han

    Memory usage is odd


      We are using Release ID: JBoss [Zion] 4.0.3SP1 (build: CVSTag=JBoss_4_0_3_SP1 date=200510231054)


      Once every few days the used memory reaches about 95% of total memory on RHEL(OS-System: Linux 2.6.18-238.el5,amd64).


      We have set a max heap size of 1280m. We have to ''free'' the memory when this happens. The only aspect that might cause

      a problem is the number of JDBC sockets lingering in the OS. Am I right ? Somehow the Java application could be opening an unbounded number

      of sockets that uses lot of memory. We are yet to scan the Java source code but I want to understand if the forum knows about this

      type of problem.


      ''top'' shows only Java at the top everytime but it does not seem to be using much memory.



      Before freeing memory

      VIRT     RES     SHR %MEM

      2764m   1.6g      16m   1.0


      After freeing memory


      VIRT     RES     SHR %MEM

      2536M   1.1g     16m   14.7


      AFAIK this is not suspicious.



        • 1. Re: Memory usage is odd

          How do you "free" the memory?

          Maybe this is a JVM problem, do you use an actual JVM version? Did you check whether it is a known JVM issue?

          • 2. Re: Memory usage is odd

            The JVM's are restarted to free the memory. The VM is 1.6.0_33


            It seems to be like this thread https://community.jboss.org/thread/146579 but we are not using NIO


            The thread https://community.jboss.org/thread/146579 points to this bug http://bugs.sun.com/view_bug.do?bug_id=6735255 which is about closing ZipInputStream. In our code there seems to be heavy usage of blob reads and writes. But not 'ZipInputStream.'


            InputStream ins = fileName.getInputStream();

            BufferedReader bug = new BufferedReader( new InputStreamReader(ins));


            'ins'  is not closed at all. Will heap monitoring track this or 'pmap' ?



            • 3. Re: Memory usage is odd

              You need to close the Stream in any case, i.e. by using a finally block.

              Otherwise you may run out of filehandles memory or other resources.

              • 4. Re: Memory usage is odd

                I agree. It is the data that is missing and the way to track it at the OS level. At this time there is no proof that it is eating up the memory. 'Used memory' is high on my RHEL.




                I believe I have found the cause. Thousands of such 'anon' blocks in the pmap output. How do I link this back to the InputStream or something else that is causing the leak ?


                0000000041fcd000       4       0       0 -----    [ anon ]

                0000000041fce000    1024      12      12 rwx--    [ anon ]

                00000000420ce000       4       0       0 -----    [ anon ]

                00000000420cf000    1024      12      12 rwx--    [ anon ]

                00000000421cf000       4       0       0 -----    [ anon ]

                00000000421d0000    1024      12      12 rwx--    [ anon ]

                00000000422d0000       4       0       0 -----    [ anon ]

                00000000422d1000    1024      12      12 rwx--    [ anon ]

                00000000423d1000       4       0       0 -----    [ anon ]

                00000000423d2000    1024      12      12 rwx--    [ anon ]

                00000000424d2000       4       0       0 -----    [ anon ]

                00000000424d3000    1024      12      12 rwx--    [ anon ]



                • 5. Re: Memory usage is odd



                  Why don't you use heapdump to analyse the issue?



                  • 6. Re: Memory usage is odd

                    I am trying that too but pmap seems to show that the JVM footprint is increasing due to increase of native memory. The heap limit is never crossed and we don't get any error like OOM. OOM is caused by native memory problems too but in this case the JVM functions but RHEL's ''used memory'' keeps on growing till we bounce JBoss. I see similary JVM problems on the net.