[RFR]8215622: Add dump to file support for jmap histo

Hohensee, Paul hohensee at amazon.com
Fri Dec 28 19:53:38 UTC 2018


Update the copyright dates to 2019 please, since this won’t get pushed until then.

In JMap.java, I’d emulate dump() and use


        String filename = null;

        String subopts[] = options.split(",");


        for (String subopt : subopts){

            if (subopt.isEmpty() || subopt.equals("all")) {

                // pass

            } else if (subopt.equals("live")) {

                liveopt = "-live";

            } else if (subopt.startsWith("file=")) {

                // file=<file> - check that <file> is specified

                if (subopt.length() > 5) {

                    filename = subopt.substring(5);

                }

            } else {

              usage(1);

            }

         }



         // get the canonical path - important to avoid just passing

         // a "heap.bin" and having the dump created in the target VM

         // working directory rather than the directory where jmap

         // is executed.

         filename = new File(filename).getCanonicalPath();

         // inspectHeap is not the same as jcmd GC.class_histogram

         executeCommandForPid(pid, "inspectheap", filename, liveopt);


I.e., use an enhanced for loop to scan the array, and duplicate dump()’s executeCommandForPid() argument order, as well as dump()’s “file=<>” check (the code that starts with “if (subopt.startsWith”) and canonicalization. Actually, better to factor the latter out into its own method and use it from both histo() and dump().

The argument checking code in heap_inspection() in attachListener.cpp can be simplified along the lines of dump_heap(). I.e., you don’t need to loop over the argument list. To match up with dump_heap()’s info messages, the info message string at the end should be “Heap inspection file created: %s”.

Thanks,

Paul

From: serviceability-dev <serviceability-dev-bounces at openjdk.java.net> on behalf of 臧琳 <zanglin5 at jd.com>
Date: Thursday, December 20, 2018 at 11:03 PM
To: "serviceability-dev at openjdk.java.net" <serviceability-dev at openjdk.java.net>
Subject: [RFR]8215622: Add dump to file support for jmap histo

Hi All,
       May I ask your help to review this patch for enhance jmap –histo.
It add the “file=<path>” arguments that allow jmap –histo outputs data to file directly.
This patch is also part of the enhancement described in https://bugs.openjdk.java.net/browse/JDK-8214535.

Webrev: http://cr.openjdk.java.net/~xiaofeya/8215622/webrev.00/
Bug: https://bugs.openjdk.java.net/browse/JDK-8215622

Thanks.

BRs,
Lin



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20181228/152a5615/attachment.html>


More information about the serviceability-dev mailing list