Skip to main content
Glama

java_heap_dump

Generate a heap dump from a Java process to identify memory leaks and analyze object allocations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYes
live_onlyNo
out_fileNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation of java_heap_dump. Uses jmap to create a heap dump, validates the file exists, and returns the result with metrics (size_bytes) and a raw_artifact_path for downstream MAT analysis.
    def java_heap_dump(pid: int, live_only: bool = True, out_file: str | None = None) -> dict[str, Any]:
        try:
            require_binary("jmap", "Install OpenJDK 17+ so jmap is available.")
            path = Path(out_file) if out_file else _artifact_dir() / f"heap-{pid}-{_timestamp()}.hprof"
            path.parent.mkdir(parents=True, exist_ok=True)
    
            mode = "live" if live_only else "all"
            dump_opt = f"-dump:{mode},format=b,file={str(path)}"
            output = ensure_success(run_command(["jmap", dump_opt, str(pid)], timeout_s=900)).stdout
        except Exception as exc:  # noqa: BLE001
            return _command_failed(exc)
    
        if not path.exists():
            return warn_result(
                evidence=[f"Heap dump command succeeded but file is missing at {path}.", output.strip()[:800]],
                metrics={"pid": pid, "requested_file": str(path)},
                confidence="low",
                next_recommended_action="Retry with explicit writable out_file and sufficient disk space.",
            )
    
        return ok_result(
            evidence=[f"Heap dump created for PID {pid}: {path}"],
            metrics={"pid": pid, "size_bytes": path.stat().st_size, "live_only": live_only},
            confidence="medium",
            next_recommended_action="Run java_mat_suspects on this heap dump.",
            raw_artifact_path=str(path),
        )
  • Registers java_heap_dump as an MCP tool via the @mcp.tool() decorator, delegating to tools.java_heap_dump.
    @mcp.tool()
    def java_heap_dump(pid: int, live_only: bool = True, out_file: str | None = None) -> dict[str, Any]:
        return tools.java_heap_dump(pid=pid, live_only=live_only, out_file=out_file)
  • Imports java_heap_dump from tools module for use in the workflow orchestration.
    from .tools import (
        java_async_alloc_profile,
        java_class_histogram,
        java_gc_snapshot,
        java_heap_dump,
        java_jfr_start,
        java_jfr_summary,
        java_list_processes,
        java_mat_suspects,
    )
  • Invocation site: calls java_heap_dump(pid=resolved_pid, live_only=True) as part of the automated heap analysis workflow.
    heap_result = java_heap_dump(pid=resolved_pid, live_only=True)
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SegfaultSorcerer/heap-seance'

If you have feedback or need assistance with the MCP directory API, please join our Discord server