JMap alternative available?
Asked Answered
T

3

6

When I ran below jmap command:

jmap -histo 14104

I am able to see very nice output of my objects, there instances, bytes used.

 num     #instances         #bytes  class name
----------------------------------------------
   1:       1308333      398374280  [C
   2:         55058       84410136  [B
   3:       1548041       49537312  java.lang.ref.Finalizer
   4:       1584594       38030256  java.util.HashMap$Entry
   5:       1327543       31861032  java.lang.String
   6:        765682       25734336  [Ljava.lang.Object;

But unfortunately this is not supported by Oracle and not available in latest Windows and Linux JDK distributions. Can someone please help suggesting alternative to jmap?

Trishatriskelion answered 5/8, 2015 at 13:17 Comment(1)
This question is premised on incorrect information. The answers explain.Altercate
N
0

First of all, jmap works for me on Windows 10 and JDK 1.8.0_192 after setting all permissions for %TMP%\hsperfdata_<username> directory.

Secondly, instead of jmap you can use VisualVM tool:

VisualVM in Memory Sampler Mode

It has a Sampler utility, which allows to check the heap histogram.

If you don't see your Java process on the left list, try with -Dcom.sun.management.jmxremote property.

Nnw answered 23/12, 2018 at 21:1 Comment(1)
I'd also want to add that from JDK 9, Visual VM is not included into Oracle JDK. But it is open source and can be downloaded from visualvm.github.ioNnw
A
0

jmap -histo does work for Oracle JDK atleast now. You can also use Jconsole for not the same but very descriptive information. You can use Jhat for the information that you see above and many other information on browser.

Ardenia answered 22/9, 2019 at 12:12 Comment(0)
A
0

But unfortunately this is not supported by Oracle and not available in latest Windows and Linux JDK distributions.

That is incorrect information.

I run Fedora 29 with OpenJDK Java 11 installed, and jmap is certainly present:

$ ls -l /usr/bin/jmap
.... /usr/bin/jmap -> /etc/alternatives/jmap
$ ls -l /etc/alternatives/jmap
.... /etc/alternatives/jmap -> /usr/lib/jvm/java-11-openjdk-11.0.4.11-0.fc29.x86_64/bin/jmap

OpenJDK Java 11 is available for Fedora (current versions), CentOS 7 & 8, RHEL 7 & 8, Ubuntu 16.04 & 18.04, Debian 9 ... to name a few.

And for Oracle distributions, I can see the jmap manual page in the Oracle Java 12 SE Documentation:

so it is safe to assume that the tool will be present when you install an Oracle JDK distribution.

Altercate answered 22/9, 2019 at 14:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.