feat(memory): v3.26.118 缩略图 512/并发 2 + 护栏改看估算进程占用
This commit is contained in:
1 parent
2a430a7382
commit
3944fc5d7e
8 files changed
+44
-10
No files matched your search
@@ -199,6 +199,9 @@
|
||||
})
|
||||
} catch (e) { /* ignore */ }
|
||||
const stat = wDiagStats(refs.nodes, refs.workspaces)
|
||||
// v3.26.118:构成只算一次(采样与护栏共用),避免每 15s 扫两遍
|
||||
let compNow = null
|
||||
try { compNow = wMemoryComposition(refs) } catch (e) { compNow = null }
|
||||
const mem = (CrashLog && typeof CrashLog.memoryNow === 'function') ? CrashLog.memoryNow() : null
|
||||
if (CrashLog && typeof CrashLog.sample === 'function') {
|
||||
let view = ''
|
||||
@@ -209,7 +212,7 @@
|
||||
// v3.87.9 泄漏仪表:这些结构一旦无上限增长就是 OOM 元凶(本次实测堆 3.3GB 而图片仅 26MB)
|
||||
history: (() => { const st = (refs.history && refs.history.stack) || []; let bytes = 0; try { for (const x of st) bytes += historySnapshotBytes(x) } catch (e) { /* ignore */ } return { depth: st.length, bytesMB: Math.round((bytes / 1048576) * 10) / 10, sweeping: (historyStore && historyStore.sweepState().sweeping) ? 1 : 0, swept: (historyStore && historyStore.sweepState().swept) || 0 } })(),
|
||||
maps: { genRuns: refs.genRuns ? refs.genRuns.size : 0, thumbs: outThumbCache.size, displayThumbs: displayThumbs.size, loadedBoards: wLoadedBoards.length },
|
||||
comp: wMemoryComposition(refs), // v3.87.18:内存构成(各结构 MB),定位 GB 级缺口用
|
||||
comp: compNow || wMemoryComposition(refs), // v3.87.18:内存构成(各结构 MB),定位 GB 级缺口用
|
||||
})
|
||||
}
|
||||
if (!mem || !mem.ratio) return
|
||||
@@ -218,9 +221,12 @@
|
||||
// 4GB 上限意味着要冲到 3.1GB 才动手,那时界面早卡死了。
|
||||
// 这里补一条**绝对占用**护栏:≥900MB 且闲置(未在保存/生成)就做一次轻量回收,
|
||||
// 回收后再看是否继续增长;不会碰用户数据(全是可重建的缓存与可反推的引用形态)。
|
||||
if (mem.usedMB >= 900 && nowMs - memReclaimAt > 120000 && !(refs && refs.saving) && !(refs && refs.genRuns && refs.genRuns.size)) {
|
||||
// v3.26.118:改看「估算进程占用」(堆 + 图片字节缓存 + 解码位图)。
|
||||
// 只看堆的话,106 张图时堆 20MB / 位图 200MB,护栏永远不动 —— 这正是「内存上来不下降」的观感来源。
|
||||
const procEst = (compNow && compNow.procEstMB > 0) ? compNow.procEstMB : mem.usedMB
|
||||
if (procEst >= 800 && nowMs - memReclaimAt > 120000 && !(refs && refs.saving) && !(refs && refs.genRuns && refs.genRuns.size)) {
|
||||
memReclaimAt = nowMs
|
||||
Promise.resolve().then(() => wReclaimMemoryNow('auto ' + mem.usedMB + 'MB')).catch(() => { /* ignore */ })
|
||||
Promise.resolve().then(() => wReclaimMemoryNow('auto est ' + procEst + 'MB')).catch(() => { /* ignore */ })
|
||||
}
|
||||
if (mem.ratio < 0.75) return
|
||||
const now = nowMs
|
||||
|
||||
Reference in new issue
Block a user