Install any skill in seconds. Free to start, no credit card required.
Get Started Free →doccker/streaming-export-safety
当代码涉及 Excel/CSV/JSON/PDF 大文件导出、批量序列化、内存里构建大对象时触发。防止 OOM、临时文件残留、同步导出阻塞 HTTP 线程等内存安全陷阱。
Passed 20 of 22 test cases with the skill, and 17 of 22 without it.
and 1 more in the full report
3 fixed17 passed either way2 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
I am building a Python API endpoint that allows users to download bulk order records in JSON format. Currently, the code fetches every database record at once and runs json.dumps() before returning the HTTP response, causing gateway timeouts and memory spikes. What is the proper strategy and code pattern to output this dataset safely without blocking the web worker or blowing up memory?
| Checked | Without skill | With skill |
|---|---|---|
| Recommends structuring the endpoint as an asynchronous background task that returns a task identifier immediately. | Missed | Passed |
| Recommends outputting JSONL (line-delimited JSON) or chunked iterative serialization instead of serializing a full JSON array in memory. | Passed | Passed |
The instructions your model reads when the skill loads.
当一次性 in-memory 构建数据超过 1 万行 / 10 MB 时,必须切换为流式 API。 否则常见后果:OOM、Full GC 风暴、临时文件残留、HTTP 超时。
| 数据量级 | 推荐模式 | 备注 |
|---|---|---|
| ≤ 1 万行 / ≤ 5 MB | 内存构建 OK | XSSFWorkbook / pandas / 普通 JSON 序列化 |
| 1 万 ~ 10 万行 | 强烈建议流式 | 单机够用,但有 OOM 风险 |
| > 10 万行 / > 50 MB | 必须流式 + 异步 | 内存模型会爆 |
| 数据量未知(用户驱动) | 必须流式 + 上限保护 | 永远按最坏情况设计 |
核心判断:能不能预估上限?预估超过 1 万行就上流式。
代码评审看到以下模式立即怀疑:
new XSSFWorkbook() + 循环 createRow 超过 1 万次EasyExcel.write(...).sheet().doWrite(data) 中 data.size() > 10000openpyxl.Workbook()(未带 write_only=True)+ 循环 appendexcelize.NewFile() + SetCellValue 大量循环ExcelJS.Workbook()(未用 stream 子模块)// ❌ XSSF 全量内存(10w 行直接 OOM)
XSSFWorkbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet();
for (int i = 0; i < 100_000; i++) {
Row row = sheet.createRow(i);
test cases passed, vs 17 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.