Solved

Increasing Allocated Memory

Posted on 2004-09-09
3
221 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 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:

786 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