hmos-jsleak-analysis

Analyzes HarmonyOS rawheap and heapsnapshot files to identify suspected JS memory leaks.

2|Updated Jun 21, 2026
One-click install
npx skills add https://github.com/IsKenKenYa/skills --skill hmos-jsleak-analysis-iskenkenya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hmos-jsleak-analysis
Source: https://github.com/IsKenKenYa/skills/tree/main/skills/harmonyos/solutions/quality/stability/hmos-jsleak-analysis
Command: npx skills add https://github.com/IsKenKenYa/skills --skill hmos-jsleak-analysis-iskenkenya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @memlab/heap-analysis, @memlab/core, and includes scripts (resource) and references (resource) components.

What problem does it solve? Diagnosing JavaScript memory leaks in HarmonyOS/ArkTS applications requires manually inspecting rawheap and heapsnapshot files, tracing reference chains to GC Roots, and correlating objects with native allocations—a slow, error-prone process. This Skill automates heap clustering, cross-snapshot comparison, and fault-mode classification to pinpoint leak suspects with root causes and fix suggestions. ## Core Features & Use Cases - Heap Conversion & Clustering: Converts .rawheap files to .heapsnapshot via platform-specific rawheap_translator binaries, then runs the Node-based heap_cluster script to produce Markdown, HTML, and JSON reports of top business and common objects by Retained Size. - Multi-Snapshot & Version Comparison: Aggregates a directory of snapshots into a cumulative leaderboard, or compares baseline vs. new version directories to surface new and growing objects indicating memory regressions. - GlobalHandler Native Stack Correlation: When explicitly requested, links GlobalHandler objects to native call stacks using rawheap + htrace + js_map three-in-one logs or a native hook DB, with aggregate fallback when address-level mapping is unavailable. - Fault Mode Classification: Matches every leak suspect against the ArkTS OOM fault mode library (ROOT_VM, ROOT_FRAME, ROOT_LOCAL_HANDLE, ROOT_GLOBAL_HANDLE) and outputs a structured report with reference chains, three-level root causes, and repair suggestions. - Use Case: A HarmonyOS developer receives a memory leak faultlog containing a .rawheap file. The Skill converts it, clusters the snapshot, identifies a large object held by a GlobalHandle root, classifies it as FM-04, and recommends adding the missing napi_delete_reference call. ## Quick Start Use the hmos-jsleak-analysis skill to analyze the memory snapshot file leak.rawheap and generate a memory leak analysis report.

Frequently Asked Questions about hmos-jsleak-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze a HarmonyOS heapsnapshot for memory leaks?

Provide the .heapsnapshot file and the Skill runs the heap_cluster.js script to cluster objects by Retained Size, producing Markdown, HTML, and JSON reports. It then classifies each suspect against the ArkTS fault mode library and outputs reference chains, root causes, and fix suggestions.

How to convert a rawheap file to heapsnapshot on HarmonyOS?

The Skill calls the platform-specific rawheap_translator binary located under scripts/windows, scripts/linux, or scripts/macos (arm64 and x64). Pass the .rawheap file and an output .heapsnapshot path, then continue with standard heap cluster analysis.

What Node version is required for heap cluster analysis?

Node 24 is preferred, with Node 22.5 as the minimum. The Skill also requires pnpm (or corepack) to install the locked @memlab/heap-analysis and @memlab/core dependencies inside the scripts/node directory before running analysis.

Can I compare memory snapshots between two app versions?

Yes. Provide baseline and current snapshot directories and the Skill runs heap_cluster.js with --compare or --compare-experimental to list new and growing objects, growth amounts, and representative reference chains, distinguishing business objects from common runtime objects.

When does GlobalHandler native stack correlation run?

It runs only when explicitly requested and the required inputs exist: either a three-in-one directory with .rawheap, .htrace, and js_map files, or a heapsnapshot plus a native hook DB. Without address-level data, it falls back to aggregate RES_ARK_GLOBAL_HANDLE statistics.

Why are weakly reachable objects excluded from leak suspects?

Objects reachable only through WeakMap, WeakSet, WeakRef, or weak edges can be collected by the GC, so they are not leak candidates. The clustering stage recomputes the shortest strong-reference chain to the GC Root and drops objects with no strong path.