<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>4.0.0</version>
</dependency>
public static void main(String[] args) {
System.out.println("Integer: " + RamUsageEstimator.sizeOf(Integer.valueOf(122)));
System.out.println("Long: " + RamUsageEstimator.sizeOf(Long.valueOf(122L)));
System.out.println("Double: " + RamUsageEstimator.sizeOf(Double.valueOf(122.22)));
System.out.println("Float: " + RamUsageEstimator.sizeOf(Float.valueOf(122.22f)));
System.out.println("Boolean: " + RamUsageEstimator.sizeOf(Boolean.valueOf(false)));
System.out.println("Character: " + RamUsageEstimator.sizeOf(Character.valueOf('a')));
System.out.println("Short: " + RamUsageEstimator.sizeOf(Short.valueOf("1")));
System.out.println("Byte: " + RamUsageEstimator.sizeOf(Byte.valueOf("1")));
System.out.println("Date: " + RamUsageEstimator.sizeOf(new Date()));
System.out.println("Object: " + RamUsageEstimator.sizeOf(new Object()));
Map<String, Object> map = new HashMap<>();
map.put("11", 11);
map.put("22", "22");
map.put("33", 33L);
map.put("44", 44.44);
System.out.println("Map: " + RamUsageEstimator.sizeOf(map));
}