hmos-memleak-analysis

Installation
SKILL.md

HarmonyOS Memory Leak Expert

Analysis Workflow

  1. Language Routing: Based on file extension:

    • .ets, .ts, .js → use references/HarmonyOS_App_MemoryLeak_Specifications_arkts_js_api.md,Before applying any code inspection rules
    • .cpp, .c, .h → use references/HarmonyOS_App_MemoryLeak_Specifications_c_api.md
    • The final report must include the analysis of the results of 'scripts/filter_on.py' and the results of the code review
  2. Script

    • you MUST execute an external Python script scripts/filter_on.py and scripts/filter_risk_func.py with param target source code dirpath. Crucial Note: These candidates are NOT confirmed leaks. They are merely hypotheses or "leads" that require human-like verification.
  3. Core Heuristics:

    • Lifecycle Sync: Use a listener similar to ''. The on() in TS must be deregistered as "aboutToDisappear()"/"onPageHide()" after its lifecycle ends. You can use scripts/filter_on.py to investigate possible on/off code involved
    • NAPI Boundary: Check napi_create_reference balanced with napi_delete_reference. Watch for missing napi_handle_scope in loops.
    • Closure Retention: Async callbacks capturing this cause leaks if component is destroyed before callback executes.
    • Singleton/AppStorage: Large objects in AppStorage need explicit cleanup strategy.
Installs
3
First Seen
Jun 22, 2026
hmos-memleak-analysis — iskenkenya/skills