Solved

Increasing Allocated Memory

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

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

Join & Write a Comment

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 …
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

759 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

20 Experts available now in Live!

Get 1:1 Help Now