Agent skill

Java Memory Leaks

by nwjs in nwjs/chromium.src

How to identify and fix Java memory leaks in Android Chrome using LeakCanary traces.

BSD-3-ClauseAuto-check passedDevelopment

Install Java Memory Leaks

skills CLI
$ npx skills add nwjs/chromium.src --skill java-memory-leaks -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install nwjs/chromium.src java-memory-leaks --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/nwjs/chromium.src.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agents/skills/java-memory-leaks .claude/skills/java-memory-leaks && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
java-memory-leaks
GitHub stars
160
Token cost
~1.4k tokens
SKILL.md length
536 words
Files
2
Skills in repo
64
Repo updated
First seen
Licence
BSD-3-Clause

At a glance

How to identify and fix Java memory leaks in Android Chrome using LeakCanary traces.

  • Works in 5 steps: Confirm the Leak → Analyze Leak Trace → Identify the Break Point → …
  • Tasks that involve Performance optimization
  • SKILL.md covers Workflow, Best Practices & Gotchas and Examples
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Java Memory Leaks is an agent skill from nwjs/chromium.src. How to identify and fix Java memory leaks in Android Chrome using LeakCanary traces.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file.

It sits in Development, covering Performance optimization. It works with Java and Android. The repository describes itself as: Chromium codebase with NW.js modifications. Based on https://chromium.googlesource.com/chromium/src.git. The licence is BSD-3-Clause.

When your agent uses it

  • Tasks that involve Performance optimization

Example prompts

  • “/java-memory-leaks”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Confirm the Leak
  2. Analyze Leak Trace
  3. Identify the Break Point
  4. Apply Fix Patterns
  5. Verify

What it can do on your machine

Read from SKILL.md and the folder at commit a9e8946. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Java Memory Leaks loads about 1.4k tokens when it runs. Until then it costs about 26 tokens; SKILL.md has 536 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~26
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from nwjs/chromium.src at commit a9e8946, republished under its BSD-3-Clause licence (© nwjs). 536 words, ~1,364 tokens.

Download SKILL.mdSave it as .claude/skills/java-memory-leaks/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
java-memory-leaks
description
How to identify and fix Java memory leaks in Android Chrome using LeakCanary traces.

Fixing Java Memory Leaks in Android Chrome

This skill guides the process of identifying, debugging, and fixing Java memory leaks in Android Chrome, typically identified by LeakCanary in instrumentation tests.

Workflow

  1. Confirm the Leak:

    • If you suspect a leak, confirm it by adding or running an instrumentation test that exercises the component.
    • If the leak does not reproduce and the test has @Batch, it may be necessary to run the whole test class to reproduce the leak.
    • Critical: Pass --enable-leak-checks to the test runner if the class lacks @EnableLeakChecks.
    • Run the test and look for LeakCanary detections in the log output.
    • Do not get sidetracked by other crashes, or even other leaks. Report these, but do not try to fix them unless they seems to be variations of the suspected leak.
  2. Analyze Leak Trace:

    • Examine the LeakCanary trace from the test failure log.
    • Identify the leaking object (usually at the bottom of the trace, marked with Leaking: YES).
    • Identify the GC Root (at the top of the trace).
    • Trace the retention path from the GC Root to the leaking object.
    • Look for Leaking: UNKNOWN nodes in between to find where the chain should be broken.
  3. Identify the Break Point:

    • Look for references that should be cleared when the activity or component is destroyed.
    • Common culprits:
      • Observers not unregistered.
      • Missing calls to destroy() on components that hold resources or observers.
      • Static variables holding references to activities or contexts.
      • Inner classes (especially anonymous ones) holding implicit references to the outer class.
      • Callbacks passed to long-lived components without lifecycle management.
  4. Apply Fix Patterns:

    • Pattern 1: Explicit Unregistration:
      • If the leak is due to an observer not being removed, ensure removeObserver() is called in onDestroy() or equivalent lifecycle teardown.
      • If the component is not a DestroyObserver, consider making it one and registering it with ActivityLifecycleDispatcher.
    • Pattern 2: Nullifying References:
      • If a field causes leaks after destruction, nullify it in onDestroy().
      • Preferred approach: Mark the field as @Nullable and add explicit null checks where needed. This is safer and satisfies NullAway without suppressions.
      • Alternative approach: If marking the field @Nullable causes too much "collateral damage" (requiring null checks in many places), you can use @SuppressWarnings("NullAway") on the onDestroy() method to set the field to null while keeping it non-null for the rest of the lifecycle.
      • Example (Preferred):
        java
        private @Nullable CustomTabActivityTabProvider mTabProvider;
        
        @Override
        public void onDestroy() {
            mTabProvider = null; // Breaks leak trace
        }
    • Pattern 3: Avoid Mutation in Observers:
      • If cleanup requires mutating state (e.g., calling removeTab()), ensure this is done by the owner of the component, not by an observer or registrar. Observers should not have side effects that mutate the observed object during teardown.
  5. Verify:

    • Rebuild the test target: autoninja -C out/Debug chrome_public_test_apk.
    • Run the specific leak test: out/Debug/bin/run_chrome_public_test_apk --enable-leak-checks -f "YourLeakTest*".
    • Verify that LeakCanary no longer reports the leak.
    • Trybot Verification: To run the LeakCanary bot on CQ / trybots, include the following footer in the CL description: Cq-Include-Trybots: luci.chromium.try:android-16-x64-leakcanary-rel
Show full SKILL.md (64 more words)Show less

Best Practices & Gotchas

  • Order of Destruction: Nullifying references in onDestroy() can cause NullPointerExceptions if other components try to use them during their own destruction (e.g., to unregister observers). Ensure that cleanup methods like unregisterObserver handle null references gracefully.
    java
    public void unregisterActivityTabObserver(CustomTabTabObserver observer) {
        mActivityTabObservers.removeObserver(observer);
        if (mTabProvider == null) return; // Guard against NPE during destruction
        Tab activeTab = mTabProvider.getTab();
        ...
    }

Examples

Nullifying References for Cleanup

Before:

java
public class MyComponent implements DestroyObserver {
    private final LongLivedProvider mProvider; // Retains activity

    public MyComponent(LongLivedProvider provider) {
        mProvider = provider;
    }

    @Override
    public void onDestroy() {
        // Provider still holds reference to this component, leaking activity
    }
}

After (Preferred):

java
public class MyComponent implements DestroyObserver {
    private @Nullable LongLivedProvider mProvider;

    public MyComponent(LongLivedProvider provider) {
        mProvider = provider;
    }

    @Override
    public void onDestroy() {
        if (mProvider != null) {
            mProvider.removeObserver(this); // If applicable
            mProvider = null; // Break the leak chain
        }
    }
}

© nwjs, BSD-3-Clause. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in agents/skills/java-memory-leaks of nwjs/chromium.src.

  • SKILL.md
  • OWNERS

Open the folder on GitHubat commit a9e8946

Compare with similar skills

Java Memory Leaks next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Java Memory Leaks compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Java Memory Leaks this skillnwjs/chromium.src160—~1.4kAutomated safety check: PassBSD-3-Clause
Caffeine Cache Optimization Experimentsben-manes/caffeine18k—~2.6kAutomated safety check: NotesApache-2.0
Android Code Quality Checkerwordpress-mobile/WordPress-Android3.2k—~587Automated safety check: PassGPL-2.0
Caffeine Performance Auditben-manes/caffeine18k—~559Automated safety check: PassApache-2.0
Groovy 5 Developer Guideapache/grails-core2.9k—~3kAutomated safety check: PassApache-2.0
Climber Step Minimizationben-manes/caffeine18k—~3kAutomated safety check: NotesApache-2.0

Similar skills

  • Runs controlled JMH experiments on the Caffeine cache to find shared contention and hot-path waste, then reviews correctness and returns a reviewable patch.

    18k GitHub stars~2.6k tokensUpdated 2 days ago
    DevelopmentAuto-check: notes
  • Android Code Quality Checker

    wordpress-mobile/WordPress-Android

    Runs detekt, checkstyle, and Android lint together, reads their reports, and proposes approved fixes grouped by file.

    3.2k GitHub stars~587 tokensUpdated today
    DevelopmentAuto-check passed
  • Caffeine Performance Audit

    ben-manes/caffeine

    Audits the Caffeine cache source for hot-path costs such as allocations, contention and memory layout, reporting only findings tied to specific lines.

    18k GitHub stars~559 tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Groovy 5 Developer Guide

    apache/grails-core

    Guidance for Groovy 5 work in Grails projects: syntax, closures, traits, DSLs, metaprogramming, Spock tests, static compilation and Java 21 integration.

    2.9k GitHub stars~3k tokensUpdated today
    DevelopmentAuto-check passed
  • Climber Step Minimization

    ben-manes/caffeine

    Prices each step of the window climber algorithm by disabling it in turn, to find steps that no longer earn their keep and branches that no longer fire.

    18k GitHub stars~3k tokensUpdated 2 days ago
    DevelopmentAuto-check: notes
  • Perftest

    BrowserWorks/waterfox-android

    Run Firefox performance tests locally or in CI. An agent skill from BrowserWorks/waterfox-android.

    379 GitHub starsUsed in 1 repo~2.3k tokens
    DevelopmentAuto-check passed

More from nwjs/chromium.src

All 64 skills in this repo
  • Analyzing SQL Traces

    nwjs/chromium.src

    Extracts raw trace data from Perfetto traces, runs arbitrary SQL queries for custom follow-up analysis, and applies expert cognitive principles (Tiered Flow Analysis, Semantic Mismatch, Redundancy)…

    160 GitHub stars~2.9k tokensUpdated 4 days ago
    Auto-check passed
  • Autonomous multi-agent performance optimization loop for Chromium and V8.

    160 GitHub stars~4.2k tokensUpdated 4 days ago
    Auto-check passed
  • Automated Tracing

    nwjs/chromium.src

    Automated Tracing & Performance Telemetry in Chromium using Perfetto and Telemetry benchmarks.

    160 GitHub stars~1.5k tokensUpdated 4 days ago
    Auto-check passed
  • Chrome Releases

    nwjs/chromium.src

    Queries Chrome commit, version, release, and milestone metadata.

    160 GitHub stars~1.3k tokensUpdated 4 days ago
    Auto-check passed
  • Chromium Docs

    nwjs/chromium.src

    Search and reference Chromium documentation from the local docs index, including design docs, APIs, and development guides.

    160 GitHub stars~1.2k tokensUpdated 4 days ago
    Auto-check passed
  • Gn Deps Debugging

    nwjs/chromium.src

    Diagnose Chromium GN dependency and include-visibility failures, including BUILD.gn deps/publicdeps, DEPS include rules, private headers, and circular dependencies.

    160 GitHub stars~1.5k tokensUpdated 4 days ago
    Auto-check passed

Works with

Categories

Questions about Java Memory Leaks

What does Java Memory Leaks do?

How to identify and fix Java memory leaks in Android Chrome using LeakCanary traces. src. How to identify and fix Java memory leaks in Android Chrome using LeakCanary traces.

When should I use Java Memory Leaks?

Java Memory Leaks fits situations like: tasks that involve Performance optimization.

How do I install Java Memory Leaks in Claude Code?

Run `npx skills add nwjs/chromium.src --skill java-memory-leaks -a claude-code`. Or copy the skill folder (agents/skills/java-memory-leaks in nwjs/chromium.src) into .claude/skills/java-memory-leaks in your project. Claude Code loads it when a task matches its description.

How do I install Java Memory Leaks in Codex?

Run `npx skills add nwjs/chromium.src --skill java-memory-leaks -a codex`. Or copy the skill folder (agents/skills/java-memory-leaks in nwjs/chromium.src) into .agents/skills/java-memory-leaks in your project. Codex loads it when a task matches its description.

Can I use Java Memory Leaks in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add nwjs/chromium.src --skill java-memory-leaks -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/java-memory-leaks, .gemini/skills/java-memory-leaks, .github/skills/java-memory-leaks and .opencode/skills/java-memory-leaks in your project.

What does Java Memory Leaks need to run?

SKILL.md names no scripts, command-line tools or credentials: Java Memory Leaks is instructions for the agent only.

Does Java Memory Leaks access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Java Memory Leaks safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Java Memory Leaks use?

Java Memory Leaks is published under the BSD-3-Clause licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Java Memory Leaks use?

About 1.4k tokens (SKILL.md is roughly 5.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Java Memory Leaks?

Skills that share tags, products or a category with Java Memory Leaks: Caffeine Cache Optimization Experiments (ben-manes/caffeine, 18k stars), Android Code Quality Checker (wordpress-mobile/WordPress-Android, 3.2k stars), Caffeine Performance Audit (ben-manes/caffeine, 18k stars) and Groovy 5 Developer Guide (apache/grails-core, 2.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Java Memory Leaks?

nwjs (a GitHub organization) maintains it in nwjs/chromium.src, which has 160 GitHub stars. The repository holds 64 skills in this directory. The repository was last updated on October 3, 2026.

Source: nwjs/chromium.src on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.