Solved

Which JVM is Bets one?

Posted on 2004-04-04
6
130 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
Comment Utility
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
Comment Utility
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
Comment Utility
its got lots of bugs, which one in particular are you referring to?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Author Comment

by:sudhakar_koundinya
Comment Utility
Regarding HEAP Meomry usage
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

763 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

9 Experts available now in Live!

Get 1:1 Help Now