Solved

Which JVM is Bets one?

Posted on 2004-04-04
6
131 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Eclipse Neon and jdk 1.8.0 11 139
factorial example 4 35
How to convert String matching to regex in java 4 21
tomcat startup error 5 21
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now