Can you calculate the shallow heap size?


News: Can you calculate the shallow heap size?

  1. In the first post in the subject we pushed a whole lot of complexity away by stating that calculating shallow heap is easy – it consists of only the heap occupied by the object itself. But how do you calculate how much memory does the object “itself? require?  Apparently there is a formula for it:

    Shallow Heap Size = [reference to the class definition] + space for superclass fields + space for instance fields + [alignment]

    If it does not seem too easy anymore, we have created a case study where this formula has been applied in practice to make it easier.

    Threaded Messages (1)

  2. come on[ Go to top ]

    What does your java run on? Mine runs on computers. Your calculations are very useful, but make no reference and I think importantly so that it is missing .... how the JVM and the hardware handle loading this object. How much of it is really loaded into L3/L2 or on-core cache?  And just what is the topological arrangement of theose hardware caches?  Will the object cause fragmentation and result in a larger footprint than just the object. Hmmm. That's an easy question for the example, but a little more difficult to answer in a start-no-stop server scenario that has had the attention of engineering beyond the codebase.