Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Which JVM is Bets one?

Posted on 2004-04-04
6
Medium Priority
?
144 Views
Last Modified: 2010-03-31
Hi All


Why I am asking this question is  Afer having a testrun on my system, program raised OutofMemoryError though my system contains 150 MB of free memory at the time  of Memory raised.

I haven't  understand why java vitrual machine is not using free mory that still exists


Following is the program to test the JVM performance


public class StringBufferTest
{
      public static void main(String[] args)
      {
            int i=0;

            StringBuffer sb=new StringBuffer(3365);
      for (i = 1; i <=10000 ; i++) {
      long t3 = System.currentTimeMillis();
        // sb=new StringBuffer(n);
            int len=sb.length();
         sb = updateStringBuffer(sb);
         String s2 = sb.toString();
      long t4 = System.currentTimeMillis();
      System.out.println("StringBuffer with initial length "+len+" took "
         +(t4 -t3) +" milliseconds for appending 3365 characters and StringBuffer size is "+sb.length()+ " and it's capacity is "+sb.capacity());

      }

      }

   public static StringBuffer updateStringBuffer(StringBuffer sb) {

      sb.append("A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text.... A Large Text....");      
      return sb;
   }
}


thanks,
sudhakar
0
Comment
Question by:sudhakar_koundinya
  • 4
  • 2
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 10755171
the vm only uses the amount of memory allocated to it.
Use the -Xmx option to increase max memory available to vm.

eg. to give it 150Mb use:
-Xmx150m
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 10755185
When I saw the articles in some web sites I saw that, Hotspot JVM(Sun's) is having know bug which can't be avoidable. Is that correct?
0
 
LVL 92

Expert Comment

by:objects
ID: 10755279
its got lots of bugs, which one in particular are you referring to?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 10755293
Regarding HEAP Meomry usage
0
 
LVL 92

Expert Comment

by:objects
ID: 10755322
Unless you can be more specific I can't help you.
As I stated originally the amount of free memory available to the OS is not related to the amount available to the vm.
If you want to increase the memory available to the vm use the -Xm option.
0
 
LVL 92

Expert Comment

by:objects
ID: 10831167
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question