• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

File size and Heap space

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I am writing to a file in Java, does the size of the file take space from the allocated memory heap? How would a 129mb file affect performance?
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tested this with a 500M+ file (the Oracle 8i zip distribution) on Win2K. The code/output is below. When the file is opened I noticed 5M being acquired on the windows memory monitor panel in the task manager but that was about it.
import java.io.*;
public class test {
public static void main(String[] args) {
try {
System.out.println(Runtime.getRuntime().totalMemory()/1024 + "K");
FileOutputStream fos = new FileOutputStream("oracle817ntee.zip", true);
System.out.println(Runtime.getRuntime().totalMemory()/1024 + "K");
Thread.currentThread().sleep(10000);
System.out.println(Runtime.getRuntime().totalMemory()/1024 + "K");
fos.close();
}
catch(Exception e) { e.printStackTrace(); }
}
}
C:\temp>java test
1984K
1984K
1984K
reply
    Bookmark Topic Watch Topic
  • New Topic