dongjoon-hyun commented on code in PR #41709:
URL: https://github.com/apache/spark/pull/41709#discussion_r1239373194


##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -2287,6 +2287,22 @@ private[spark] object Utils extends Logging with 
SparkClassUtils {
     }.map(threadInfoToThreadStackTrace)
   }
 
+  /** Return a heap dump. Used to capture dumps for the web UI */
+  def getHeapHistogram(): Array[String] = {
+    val pid = String.valueOf(ProcessHandle.current().pid())
+    val builder = new ProcessBuilder("jmap", "-histo:live", pid)

Review Comment:
   We are inside `JVM` already.
   ```
   $ docker run -it --rm openjdk:11 bash
   root@d7d08a90ec41:/# jshell
   Jun 23, 2023 6:30:14 AM java.util.prefs.FileSystemPreferences$1 run
   INFO: Created user preferences directory.
   |  Welcome to JShell -- Version 11.0.16
   |  For an introduction type: /help intro
   
   jshell> var p = new ProcessBuilder("jmap", "-histo:live", 
String.valueOf(ProcessHandle.current().pid())).start()
   p ==> Process[pid=77, exitValue="not exited"]
   
   jshell> var r = new BufferedReader(new InputStreamReader(p.getInputStream()))
   r ==> java.io.BufferedReader@5fa7e7ff
   
   jshell> var line = ""
   line ==> ""
   
   jshell> while (line != null) { line = r.readLine(); 
System.out.println(line); }
    num     #instances         #bytes  class name (module)
   -------------------------------------------------------
      1:          8938         412040  [B ([email protected])
      2:          8705         208920  java.lang.String ([email protected])
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to