Wednesday, September 19, 2018

How to calculate memory used by an object

this article required classmexer.
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!!

1 comment:

  1. Harrah's Cherokee Casino & Hotel - Mapyro
    › mapyro › harrahs-cherokee 경기도 출장샵 › mapyro › harrahs-cherokee Harrah's Cherokee Casino & Hotel is located in the beautiful mountains of Western North Carolina. 출장마사지 Harrah's 광주 출장샵 Cherokee 화성 출장마사지 Casino is one of the most visited 목포 출장안마

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...