Skip to end of banner
Go to start of banner

Calculation of object sizes

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Requirements

All inspectIT transfer objects (see Domain model) have to be able to report its approximate size in bytes.

Approach

The calculation is for each object is done by summing these values:

  • Size of object's super class object. If object's class is directly extended from java.lang.Object class, this value is by default 8 bytes.
  • Size of all primitive types and references defined in the class.
  • If object has references to other non-inspectIT objects like String, Timestamps, Lists, Maps, Sets, etc., basic size of these objects.
  • If object has references to Collections, size of all objects in collection.

The following table shows the overview on current inspectIT transfer objects with defined primitive types and references. It also shows the formulas that are used to calculate the basic size of non-inspectIT objects: ObjectSizesTable.ods

Realization

Abstract class DefaultData will define a method long getObjectSize(IObjectSizes) which has to be overridden by all subclasses.

When updating the structure inspectIT transfer objects (e.g. adding new primitives or references), be sure to alter the mentioned method.

IObjectSizes interface

This interface provides the utility functions for calculating the object size of non-inspectIT objects. Implementations of this interface have to define also the size of the reference to an object. In 32-bit VM architecture reference is 4 bytes, and in 64-bit is 8 bytes. However, the 64-bit VM can run with compressed oops, that shrink the reference size.

For getting the object size the mentioned getObjectSize method has to be invoked with proper implementation of IObjectSizes that depends on VM architecture.

  • No labels