...
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 The interface Sizable has been introduced with only one method long getObjectSize(IObjectSizes) which has to be overridden by all subclasses. The DefaultData class implements this interface, but all sub-classes of mention class should override the method and provide correct calculations.
Note |
---|
When updating the structure inspectIT transfer objects (e.g. adding new primitives or references), be sure to alter the mentioned method. |
...
For getting the object size the mentioned getObjectSize method has to be invoked with proper implementation of IObjectSizes that depends on VM architecture.
The class AbstractObjectSizes provides methods for calculation of generally used objects like Strings, Arrays, Lists, Maps, etc.
Testing
There are several test that assure that object calculation is as accurate as possible.
- ObjectSizesPrimitiveTypesSizeTest - test that all DefaultData objects are calling the IObjectSizes.getPrimitiveTypesSize() with correct number of references, booleans, ints,.. This will fail if a developer adds the new field to the arbitrary DefaultData class, but forgets to update the size calulcation of the class.
MemoryCalculationTest - This tests uses the Classmexer java agent to prove that our calculations are correct. The tests tries to test as much different objects and classes as possible. The Classmexer has to be started with the test with the -javaagent option. If you want to start the test from Eclipse you need to do a Ivy > Retrieve on the CMR project and add the following line to the VM arguments in the Run Configuration:
Code Block -javaagent:[PATH_TO_CMR_FOLDER]/lib/test/classmexer.jar -Xms1024m -Xmx1024m -Xmn384M