# hdCaptureMode

Allows users to specify a custom command to be executed for capturing or locating a heap dump file, enabling users to dynamically determine or generate a heap dump file path during the capture process.
The command should output a valid file path, which will be used for heap dump capture.

Type: string

Default: ""

How it works internally?

  • Executed only when hdPath is not explicitly provided.
  • The yc-360 script runs the command via /bin/sh -c, injecting pid as an environment variable.
  • The script's output (stdout) must return a valid heap dump file path.
  • The returned path is used for heap dump collection.

Example (YAML):

Run jcmd to generate heap dump data and echo the file path:

options:
  hdCaptureMode: "jcmd $pid GC.heap_dump /tmp/heap_$pid.hprof && echo /tmp/heap_$pid.hprof"
1
2

Run inside a Docker container and locate a heap dump file:

./yc -hdCaptureCmd "docker exec $(docker ps -q --filter label=app.pid=$pid) jcmd $pid GC.heap_dump /logs/heap_$pid.hprof && echo /logs/heap_$pid.hprof"
1

Example (CLI):

Run jcmd to generate heap dump data and echo the file path:

./yc -hdCaptureCmd "jcmd $pid GC.heap_dump /tmp/heap_$pid.hprof && echo /tmp/heap_$pid.hprof"
1

Run inside a Docker container and locate a heap dump file:

./yc -hdCaptureCmd "docker exec $(docker ps -q --filter label=app.pid=$pid) jcmd $pid GC.heap_dump /logs/heap_$pid.hprof && echo /logs/heap_$pid.hprof"
1