Jvm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    #1

    Jvm

    Hi All,

    I have JVM OutOfMemory Error in my java program. What is this?
    How can i resolve it?

    Thanks,
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by rsrinivasan
    Hi All,

    I have JVM OutOfMemory Error in my java program. What is this?
    How can i resolve it?

    Thanks,
    It is exactly what it says. You are simply running out of memory.
    The reasons could be an infinite loop somewhere in your code causing memory to be used up or simply that your program does extensive memory demanding operations.
    If your code is not too long you can post the code around the area that's being reported for the error.
    If your code is fine then you can consider increasing the heap size when running your program.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by rsrinivasan
      Hi All,

      I have JVM OutOfMemory Error in my java program. What is this?
      How can i resolve it?

      Thanks,
      It means that your application wants even more memory while it already had used
      all the available memory. You have a 'memory leak' somewhere in your application.

      Without seeing your appliation we can't say anything more specific.

      kind regards,

      Jos

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        I didn't have my espresso yet, so this one doesn't count ;-)

        kind regards,

        Jos

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by JosAH
          I didn't have my espresso yet, so this one doesn't count ;-)

          kind regards,

          Jos
          ... and I'm just having my Rooibos tea so it can get worse.

          Comment

          • rsrinivasan
            New Member
            • Mar 2007
            • 221

            #6
            Originally posted by r035198x
            It is exactly what it says. You are simply running out of memory.
            The reasons could be an infinite loop somewhere in your code causing memory to be used up or simply that your program does extensive memory demanding operations.
            If your code is not too long you can post the code around the area that's being reported for the error.
            If your code is fine then you can consider increasing the heap size when running your program.
            Hi,
            Ya, my program runs lakhs of records at a time. I need to increase the memory size. how do i do it?

            Thanks,

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by rsrinivasan
              Hi,
              Ya, my program runs lakhs of records at a time. I need to increase the memory size. how do i do it?

              Thanks,
              It could still be a logic problem somewhere you know ...
              Code:
               java -Xmx<HeapSize> -cp  <ClassPath> <YourMainClass>
              Last edited by r035198x; Sep 18 '07, 07:17 AM. Reason: some text got snapped up somewhere

              Comment

              • rsrinivasan
                New Member
                • Mar 2007
                • 221

                #8
                Originally posted by r035198x
                It could still be a logic problem somewhere you know ...
                Code:
                 java -Xmx<HeapSize> -cp  <ClassPath> <YourMainClass>
                Hi all,

                How do i find the heap size of my JVM.

                Thanks,

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by rsrinivasan
                  Hi all,

                  How do i find the heap size of my JVM.

                  Thanks,
                  Have a look at the methods in the Runtime class.

                  Comment

                  • rsrinivasan
                    New Member
                    • Mar 2007
                    • 221

                    #10
                    Originally posted by r035198x
                    Have a look at the methods in the Runtime class.
                    Hi,

                    Code:
                    class Status 
                    {
                    	public static void main(String[] args) 
                    	{
                    		Runtime rt = Runtime.getRuntime();
                    		System.out.println(rt.totalMemory());
                    		System.out.println(rt.maxMemory());
                    		System.out.println(rt.freeMemory());
                    	}
                    }

                    I ran the above program and gets the result as

                    Result:
                    2031616
                    66650112
                    1911544

                    But my total RAM memory size is 512 MB.
                    How it is possible?

                    Thanks,

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Originally posted by rsrinivasan
                      Hi,

                      Code:
                      class Status 
                      {
                      	public static void main(String[] args) 
                      	{
                      		Runtime rt = Runtime.getRuntime();
                      		System.out.println(rt.totalMemory());
                      		System.out.println(rt.maxMemory());
                      		System.out.println(rt.freeMemory());
                      	}
                      }

                      I ran the above program and gets the result as

                      Result:
                      2031616
                      66650112
                      1911544

                      But my total RAM memory size is 512 MB.
                      How it is possible?

                      Thanks,
                      What values did you expect to get? Remember you have other processes running that are competing for this memory and the JVM uses an initial heap size.

                      Comment

                      • rsrinivasan
                        New Member
                        • Mar 2007
                        • 221

                        #12
                        Originally posted by r035198x
                        What values did you expect to get? Remember you have other processes running that are competing for this memory and the JVM uses an initial heap size.
                        Hi,
                        When i run "startup.exe" from tomcat_home/bin, it did not through "Out Of Memory" Exception. But when i run the tomcat services, i have "Out Of Memory" Exception. How can i solve it?

                        Thanks,

                        Comment

                        • nickyeng
                          Contributor
                          • Nov 2006
                          • 252

                          #13
                          i have the same error ...

                          several days already and i still can't solve it.

                          sad

                          from
                          Nick

                          Comment

                          Working...