• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How big an object is an issue for heap memory

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic