How to Estimate Object Memory Allocation in Java

Estimating Allocated Memory (Not Object Size)

Previously, I explained how to calculate an object's size considering OS binary or types of objects and primitives. In this article, I'll only review ways to estimate the size of already allocated memory for a given object. There are a couple of ways to do it. Here we review the most popular.

Estimating Memory Using Profiler

The easiest way to estimate the memory of some objects is to look right inside JVM's memory using a profiler such as Visual VM