Solved

Increasing Allocated Memory

Posted on 2004-09-09
3
230 Views
Last Modified: 2006-11-17

 sciuriware,

from http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21121871.html#12015860

I am also in need of that code. I have tested ur code. But I do not understand how to include with in classes.

1. When I execute this I use Java.exe as Runtime JVM whereas ur application takes javaw as runtime JVM. May I know the reason for this
2. When I tested this I am not getting anythig printed on screen. Is my perception of understanding that code is wrong??
Please clarify me

Thanks
Sudhakar



             public static void main(String[] argv) throws Throwable
          {
             
                new NeedMemory().needMemory(400, argv); // 400Mb limit, 200Mb initial.
                    System.err.println("Hello There");
                    StringBuffer sb=new StringBuffer("Hello World ");
                    try
                 {
                    while(true)
                 {
                         sb.append(sb.toString());
                                          System.err.println(sb.length());
                 }
                 }
                 catch(Throwable e)
                 {
                      System.err.println(sb.length());
                 }
                 System.err.println(sb.length());
            }

Sudhakar Chavli
0
Comment
Question by:sudhakar_koundinya
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
sciuriware earned 50 total points
ID: 12018820
I must admit that the javaw thing is a MSWindows java that avoids an MSDOS box.

Do you realise that the above code explodes like a bomb?

Feel free to change the code I posted.
It works for me and for the original questioner.
If you understand it, you can change it to your needs.


I'm going home now. See you.

;JOOP!
0
 
LVL 14

Author Comment

by:sudhakar_koundinya
ID: 12019074
>>Do you realise that the above code explodes like a bomb?

That is what I am facing. Some times it  takes entire RAM. Why So??
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12023882
Because it never stops doubling a String; even some ExaBytes of memory (a lot) are not enough!

;JOOP!
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
print map entry 34 71
Maven Project: Hibernate Dependencies Conflict 10 37
java jdbc batch example 8 39
Which non-HTML GUI front end to use with Java? 3 24
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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This video teaches viewers about errors in exception handling.
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.

791 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