Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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

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,
Posts: 27375
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.
keep an eye out for scorpions and black widows. But the tiny ads are safe.
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic