File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How big an object is an issue for heap memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How big an object is an issue for heap memory" Watch "How big an object is an issue for heap memory" New topic
Author

How big an object is an issue for heap memory

Doshi Milan
Ranch Hand

Joined: May 29, 2001
Posts: 112
Hi,

In our apllication we read files of 8 MB and images / PDF's of similar size. We need to have some of them atleast as an Object in Memory to work on them.

We have a Heap size allocation of 1 GB and RAM of 4 GB. Would this be an issue ?

What is normal in Java world as far the Object size is concerned ?

Thanks for any insight,
Milan
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Well, if you read an 8MB file into a byte array, it requires 8MB to store the bytes and some trifling amount (a few bytes) to keep track of the fact that it's a byte array. That's less than 1% of a gigabyte. But if you unpack those bytes into some kind of object structure that represents the contents of the file, you will require more memory.

How much more? It depends on your objects. But basically, if your strategy is to load large objects entirely into memory then you are asking for trouble. Next week somebody will produce a 10MB file, then a 50MB file next year, and so on. File sizes are growing faster than available memory, so eventually that strategy will fail to scale.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How big an object is an issue for heap memory