Solved

Which JVM is Bets one?

Posted on 2004-04-04
6
133 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 50 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

839 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