修复历史记录累积后 refresh_history 触发 macOS SIGKILL
根因: - refresh_history 每次调用都 history_list.clear() + 重建全部条目 - 每条加载 2K PNG 原图做 QPixmap (~16MB 解码) 再缩到 120x120 - 106 条历史 × 16MB = ~1.7GB 瞬时内存峰值 - macOS 内存压力触发 SIGKILL,不可被 faulthandler 捕获 - 日志里只有 "开始刷新" 没有 "加载到 N 条",确认死在 clear()/load 之间 修复: - HistoryManager 新增 thumb_path_for + get_or_create_thumbnail: 用 PIL 生成 240x240 JPEG 缓存到 <record_dir>/thumb.jpg, 基于 mtime 判断是否重新生成 - save_generation 保存原图后顺便生成缩略图 (失败不影响主流程) - refresh_history 只加载 thumb.jpg, 内存峰值从 1.7GB → 6MB (280x 下降) - 缩略图生成失败用占位图兜底, 不回退加载原图 (防回到危险路径) - 首次升级会为 106 条存量一次性补生成 thumb.jpg (PIL 串行 ~32MB 峰值, 安全) 附加: - refresh_history 增加 "刷新完成" 收尾日志, 便于下次若再崩定位死亡位置 跨平台: 纯 PIL + pathlib + Qt 标准 API, Windows 零回归 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Showing
1 changed file
with
57 additions
and
10 deletions
-
Please register or sign in to post a comment