← 返回
未分类 中文

Resource Leak

Files, sockets, subscriptions, or other finite resources are acquired without a guaranteed release path.
文件、套接字、订阅或其他有限资源在获取时没有保证的释放路径。
mvogt99
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 288
下载
💾 0
安装
1
版本
#latest

概述

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.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-08 01:11 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Hallucinated Paths

mvogt99
回复引用了当前项目中不存在的文件路径、目录或模块位置。
★ 0 📥 343

Truncated Output

mvogt99
回复在句子或代码块中途结束,因模型达到 token 限制或被截断。
★ 0 📥 336

Analysis Missing Tradeoffs

mvogt99
分析仅呈现单一选项,未比较替代方案,也未说明所选方案的成本。
★ 0 📥 607