Other v1.0.0

resource-leak

Files, sockets, subscriptions, or other finite resources are acquired without a guaranteed release path.

mvogt99 更新于 2026-04-27 1 浏览
下载 SKILL

技能说明

Files, sockets, subscriptions, or other finite resources are acquired without a guaranteed release path.

使用场景

A resource is opened but not closed. Under low load the process recycles or the OS cleans up on exit, so the bug stays hidden. Under real load, file-descriptor exhaustion, memory bloat, or orphaned connections appear and cascade.

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

帮我下载并安装这个SKILL:https://skillhub.cstcloud.cn/download/resource-leak
  1. 点击上方「下载 SKILL」按钮,获取技能压缩包。
  2. 将压缩包解压到你的 Agent 技能目录。
  3. 重启客户端后即可在技能列表中选择该技能。

技能文件内容

4 个文件 · 16 kB
SKILL.md text/markdown
---
name: resource-leak
description: Files, sockets, subscriptions, or other finite resources are acquired without a guaranteed release path.
emoji: 💧
metadata:
  clawdis:
    os: [macos, linux, windows]
---

# resource-leak

A resource is opened but not closed. Under low load the process recycles or the OS cleans up on exit, so the bug stays hidden. Under real load, file-descriptor exhaustion, memory bloat, or orphaned connections appear and cascade.

## Symptoms

- `open(...)` without a matching `close()` or `with` block.
- Database connections or HTTP clients instantiated per-request without pooling or teardown.
- Event listeners / observers / subscriptions registered but never removed.
- Background tasks or timers spawned without cancellation paths.
- Gradual memory growth that correlates with request count.

## What to do

- Pair every acquire with a release. Use language constructs that guarantee teardown: `with` (Python), `using` / `try-with-resources` (C#/Java), `defer` (Go), `try/finally` (JS/TS).
- For resources that outlive a single function, document ownership: who closes it, when, on which code path — including error paths.
- Prefer pooled clients (HTTP, database) over creating a new one per call.
- When registering event listeners, return the unregister function in the same scope so the caller can clean up.
- Test the teardown path. Kill a process or trigger an error mid-operation and confirm resources are released.

文件内容直接读取自技能仓库,仅供安装前审阅;以实际下载的压缩包为准。