rdk-memory-audit
Skill1 starsChanged 3 months agoApache-2.0View on GitHub
Measure DRAM and CMA/ION memory on D-Robotics RDK devices and verify reclamation with before/after data. Use when the user asks how much memory is left, wants to measure or free memory, or mentions drop_caches, CMA, ION, ion alloc failed. Triggers include 内存不够, 内存不足, 还剩多少内存, 实测内存, 腾出内存, 释放内存, 清缓存, 内存够不够. Do not use to stop the desktop or services (rdk-headless-mode) and do not quote doc theory instead of live measurement.
2 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- D-Robotics/rdk-device-skillsedited, first seen Oct 15, 2026
- D-Robotics/rdk-skillsedited, first seen Oct 9, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- D-Robotics/rdk-skills★ 599% same
- D-Robotics/rdk-device-skills★ 499% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository59 other files it gives its agents.
- bsp-bootloader-buildSkill
- bsp-deb-buildSkill
- bsp-env-setupSkill
- bsp-image-buildSkill
- bsp-kernel-buildSkill
- bsp-rootfs-customSkill
- bsp-source-syncSkill
- bsp-s-seriesSkill
- hmct-workflowSkill
- horizon-routerSkill
- ucpSkill
- x5-accuracy-diagnosticsSkill
- x5-board-monitorSkill
- x5-bpu-python-apiSkill
- x5-calibration-data-prepareSkill
- x5-consistency-diagnosticsSkill
- x5-environment-installSkill
- x5-environment-probeSkill
- x5-environment-setupSkill
- x5-model-diagnosticsSkill
- x5-model-preflightSkill
- x5-performance-diagnosticsSkill
- x5-ptq-compileSkill
- x5-ptq-config-authoringSkill
- x5-ptq-deploySkill
- x5-qat-adaptationSkill
- x5-qat-compileSkill
- x5-qat-deploySkill
- x5-qat-trainingSkill
- x5-routerSkill
- x5-runtime-cpp-inferSkill
- x5-runtime-deploySkill
- x5-runtime-perf-evalSkill
- rdk-accessoriesSkill
- rdk-board-delegateSkill
- rdk-board-knowledgeSkill
- rdk-camera-setupSkill
- rdk-command-manualSkill
- rdk-diagnosticSkill
- rdk-docs-referenceSkill
- rdk-ecosystemSkill
- rdk-embodied-lerobotSkill
- rdk-gpio-40pinSkill
- rdk-hardwareSkill
- rdk-headless-modeSkill
- rdk-llm-deploymentSkill
- rdk-log-forensicsSkill
- rdk-model-benchmarkSkill
- rdk-model-deploySkill
- rdk-model-zooSkill
- rdk-multimediaSkill
- rdk-network-remoteSkill
- rdk-peripheral-cookbookSkill
- rdk-source-mapSkill
- rdk-system-configSkill
- rdk-system-maintainSkill
- rdk-tros-setupSkill
- rdk-vision-pipelineSkill
- d-robotics-pack-installerSkill
The file
Files
RDK Memory Audit
聚焦内存的审计闭环:先测量、再回收、再验证。所有结论必须来自 scripts/audit.sh 的
实测数据,禁止凭经验估算 RDK 的可回收内存。
Purpose
对 RDK 的 DRAM 与 CMA/ION 内存做基线测量,在执行回收动作(drop caches、关停进程) 前后用同一脚本对比验证,产出"回收了多少、来自哪里"的可信结论。
When to use
当用户提出以下问题时激活:
- "RDK 内存不够了,还能腾出来多少?"
- "现在还剩多少内存?帮我实测一下。"
- "帮我清一下缓存 / 清掉所有缓存。"
- "跑这个模型之前先看看内存够不够。"
- "drop_caches 到底有没有用?释放了多少?"
- "CMA / ION 被谁占了?"
- rdk-diagnostic 报告
memory_kb.available偏低后的深入分析。
不要用本技能停服务或改系统配置——关停桌面/服务请交接 rdk-headless-mode。
本技能唯一的变更动作是 --apply 门控下的 drop_caches。
Prerequisites
- 在 RDK 主机上运行。
--apply回收步骤需要 root(写/proc/sys/vm/drop_caches)。
Available Scripts
| Script | Purpose | Arguments |
scripts/audit.sh | 输出 JSON 内存审计:DRAM、CMA、swap、Top RSS 进程。 | --label <name> |
scripts/reclaim_verify.sh | 基线 → 回收 → 复测的完整闭环;默认 dry-run,只有 --apply 才真正执行 drop_caches。 | --apply |
Instructions
- 运行
scripts/audit.sh --label baseline获取基线。 - 需要验证回收效果时,运行
scripts/reclaim_verify.sh(dry-run 预览动作)。 - 用户明确同意后,以 root 运行
scripts/reclaim_verify.sh --apply,脚本自动输出 before/after 差值。 - 报告时引用脚本输出的
reclaimed_kb字段,注明数据来自实测。 - 回收后仍不够用时的后续路径(按收益排序):
- 常驻占用大 → 交接 rdk-headless-mode 关停桌面/非必要服务;
- 模型/CMA 压力大 → 交接 rdk-model-deploy 换小模型;
- 仍需扩展虚拟内存 → swap/zram 属通用 Linux 手段,非 RDK 专有结论;先用 rdk-docs-reference 检索官方文档是否有对应板卡的 swap 指引,有则引用原文; 无官方指引时明确告知用户这是通用方案,且 TF 卡 swap 有磨损与性能代价, 由用户决策后再执行。
如果运行时不自动解析技能相对路径,使用 {baseDir} 占位符:
{baseDir}/scripts/audit.sh
{baseDir}/scripts/reclaim_verify.sh --applyOutput contract for audit.sh
{
"label": "baseline",
"timestamp": "2026-07-26T15:00:00+08:00",
"memory_kb": { "total": 4045884, "available": 2837520, "cached": 812340, "buffers": 40210 },
"cma_kb": { "total": 262144, "free": 180224 },
"swap_kb": { "total": 0, "free": 0 },
"top_rss": [ { "pid": 4321, "cmd": "python3", "rss_kb": 512000 } ]
}reclaim_verify.sh --apply 额外输出:
{ "before_available_kb": 2837520, "after_available_kb": 3122040, "reclaimed_kb": 284520 }Limitations
drop_caches只回收 page cache / dentry / inode,不会回收 CMA/ION 中被驱动或 模型持有的内存;CMA 占用需要定位持有进程后交由用户决定是否关停。- 非 root 运行时
reclaim_verify.sh --apply会失败并明确报错,不要静默降级。 - 不得根据"经验值"估算可回收内存;一切以脚本 before/after 差值为准。
Error handling
- 写
/proc/sys/vm/drop_caches权限不足时,报告需要 root 并给出 sudo 命令,不要伪造 after 数据。 - 如果 after 值高于 before(负回收),如实报告——期间可能有进程释放/申请内存,建议复测。
Safety
默认只读;唯一的变更动作(drop_caches)必须显式 --apply 且经用户确认。drop_caches
是内核支持的安全操作,不会导致数据丢失,但会造成短暂的缓存冷启动性能下降。
基于审计结论的进一步动作请交接:
- rdk-headless-mode — 关停桌面与非必要服务以释放常驻内存
- rdk-model-deploy — 更换更小的模型或单核绑定以降低 CMA 压力
Cross-platform behavior
全系 RDK 板卡(X3 / X5 / Ultra / S100 / S600)行为一致;CMA 字段依赖内核 CmaTotal/CmaFree
暴露,缺失时报告 null 并说明。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

