Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 762595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:25:07+00:00 2026-05-14T16:25:07+00:00

I would like to ask about Memory Overhead in java, I have a large

  • 0

I would like to ask about Memory Overhead in java,
I have a large ArrayList (61,770 items), and trying to calculate the amount of memory taken by each item (counting the object and its ArrayList entry),
by profiling the app i get that after all the data is loaded, the heap takes ~ 25Mb.
when the ArrayList has only 2 items the heap takes ~1Mb , so roughly:

(24*1024*1024)/61,768 = 407 bytes.

however, when i count the fields of the each object, i get 148 bytes(not including the ArrayList, and assuming int=4,float=4,reference=4), I am curious to know where did all of those extra bytes came from…

i can guess that since the objects I store in the ArrayList are implementing an interface, they store extra values, maybe the VM stores a 4byte function pointer for each implemented method?
the interface they implement have 20 functions so thats 80 more bytes, totaling 228 bytes, still not close to the 400 bytes measured.

any help would be appreciated.


wow, thanks for all the great answers.

@Bolo: thanks for the link ,with this class i measure ~350 bytes per object so I can least confirm the source of the large memory usage.

@Yuval A: thank you for that presentation, a valuable source of information.

@Ukko: point noted.

@Jayan: right now NetBeans profiler is giving me errors when i try to dump the heap, will try later again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:25:07+00:00Added an answer on May 14, 2026 at 4:25 pm

    These results are not surprising. The JVM adds enormous amounts of overhead to each object.

    About double the expected size for a single object, due to JVM memory overhead, is not uncommon.

    This presentation has a wonderful, in-depth, explanation and overview of various data structure memory usage in Java.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask you about regular expressions preg_match have outlined below. I
I have been reading about unsafePerformIO lately, and I would like to ask you
I would like to ask about the memory management problems in objective C. I
I would like to ask about the performance and memory usage of instantiating an
I would like to ask about memory management with regards to MKReverseGeocoder , prior
I have a few questions I would like to ask about string literals and
Hi i would like ask you about .htacess 301 redirect: I have many dynamic
I would like to ask about the effect of writing to global memory in
I would like to ask about the available (free or not) Static and Dynamic
I would like to ask you about some advices about this code. It works,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.