before start make sure download the classmexer dependency from here or classmexer 0.0.3.
1. extract and put the classmexer.jar in classpath.
2. call classmexer api to calculate memory usage.
Product p= retrieveProductFromDB();
System.out.println("Size of product is " + MemoryUtil.deepMemoryUsageOf(p));
System.out.println("Size of product is " + MemoryUtil.deepMemoryUsageOf(p, VisibilityFilter.ALL));
System.out.println("Size of product is " + MemoryUtil.memoryUsageOf(p));
Done!!
No comments:
Post a Comment