Integrated: 8176026: SA: Huge heap sizes cause a negative value to be displayed in the jhisto heap total

Koichi Sakata ksakata at openjdk.java.net
Thu Apr 1 04:13:30 UTC 2021


On Fri, 19 Mar 2021 11:49:39 GMT, Koichi Sakata <ksakata at openjdk.org> wrote:

> When a heap is used more than about 2.1GB, clhsdb jhisto shows a negative number in the total field.
> 
> $ java -Xmx20g Sample
> 
> $ jhsdb clhsdb --pid 5773
> Attaching to process 5773, please wait...
> hsdb> jhisto
> ...
> 299:            1       16      jdk.internal.misc.Unsafe
> 300:            3402    10737610256     byte[]
> Total :         15823   -2146661280
> Heap traversal took 1.793 seconds.
> (Incidentally, the Sample is a program that only allocates many objects.)
> 
> #### Details
> This is because in ObjectHistogram class the totalSize variable is int type.
> 
> The total size is the total of ObjectHistogramElement#getSize() and getSize() returns long. So I changed int to long in the ObjectHistogram class.
> 
> Additionally, I changed the type of the totalCount. This doesn't cause a bug, but ObjectHistogramElement#getCount() also returns long. So it doesn't need to treat it as int, I think. ObjectHistogramElement#compare() also do the same thing, so a class that is a huge size show the bottom of the list.
> 
> #### Tests
> The jtreg test was successful.
> $ sudo make run-test TEST=serviceability/sa/ClhsdbJhisto.java
> 
> $ cat build/linux-x86_64-server-fastdebug/test-results/jtreg_test_hotspot_jtreg_serviceability_sa_ClhsdbJhisto_java/text/summary.txt
> serviceability/sa/ClhsdbJhisto.java  Passed. Execution successful
> 
> I confirmed the output with the same program.
> 
> $ ./jdk/build/linux-x86_64-server-fastdebug/jdk/bin/java -Xmx20g Sample
> $ ./jdk/build/linux-x86_64-server-fastdebug/jdk/bin/jhsdb clhsdb --pid 10196
> Attaching to process 10196, please wait...
> hsdb> jhisto
> Object Histogram:
> 
> num       #instances    #bytes  Class description
> --------------------------------------------------------------------------
> 1:              3405    13958838400     byte[]
> 2:              887     109032  java.lang.Class
> ...
> 300:            1       16      jdk.internal.misc.Unsafe
> Total :         15827   13959470288
> Heap traversal took 1.72 seconds.

This pull request has now been integrated.

Changeset: 39f0b27a
Author:    Koichi Sakata <ksakata at openjdk.org>
Committer: Yasumasa Suenaga <ysuenaga at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/39f0b27a
Stats:     5 lines in 2 files changed: 0 ins; 0 del; 5 mod

8176026: SA: Huge heap sizes cause a negative value to be displayed in the jhisto heap total

Reviewed-by: cjplummer, kevinw, ysuenaga

-------------

PR: https://git.openjdk.java.net/jdk/pull/3087


More information about the serviceability-dev mailing list