Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.OutOfMemoryError: Java heap space

807606May 17 2007 — edited May 22 2007
Hello All,
we have application which is on swings,
in our application we have module called Report Generation
here in Report module we are generating the report and writing or saving it in .XML extension file.
for writing .XMl extension is the following is the code
writingReport() {
 String filename = System.getProperty("user.home") +"/Report.xml";
                System.out.println("XML Report file path" +filename);
                File myfile = new File(filename);
                FileWriter mywriter = null;
                BufferedReader reader = null;
                try{
                    mywriter = new FileWriter(myfile);
                     System.out.println("Now I'm reading each line from Online-Report and Displaying each line");
                    // Reading from Online-Report .
                    reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                    // where 'conn' is URLConnection   
                    String line = "";
                    System.out.println("*************Each Line Display from Online Report***************");
                    while ((line = reader.readLine()) != null) {
                        
                        System.out.println(line);
                        mywriter.write(line);
                    //    System.out.println("Each Line Display from Report.XML" +line);
                    }
                    System.out.println("Report has been written to " + myfile );
                    System.out.println(myfile +"is a Temproray file,deleted after once reading the content");
                    reader.close();
                    mywriter.close();
                }catch(Exception e){
                    e.printStackTrace();
                    try {
                        reader.close();
                        mywriter.close();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                }
}
For the above i'm getting following error
Exception in thread "Thread-6" java.lang.OutOfMemoryError: Java heap space
Output For above code:-
XML Report file pathC:\Documents and Settings\Administrator/Report.xml
Now I'm reading each line from Online-Report and Displaying each line
*************Each Line Display from Online Report***************
<?xml version="1.0" standalone="yes"?>

Exception in thread "Thread-6" java.lang.OutOfMemoryError: Java heap space


1: How can we increase the heap memory?
2: What is Default size of the BufferedReader ? is there any possiblity of increasing the BufferedReader ?

Please acknoweldge me...


Thanks in advance
Anil Patil
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 19 2007
Added on May 17 2007
15 comments
686 views