?
Solved

Which JVM is Bets one?

Posted on 2004-04-04
6
Medium Priority
?
137 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 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