• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How big an object is an issue for heap memory

 
Doshi Milan
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic