MCPcopy Create free account
hub / github.com/esengine/esengine / compact

Method compact

packages/core/src/Utils/Pool/Pool.ts:126–138  ·  view source on GitHub ↗

* 压缩池(移除多余的对象) * @param targetSize 目标大小,默认为当前大小的一半

(targetSize?: number)

Source from the content-addressed store, hash-verified

124 * @param targetSize 目标大小,默认为当前大小的一半
125 */
126 public compact(targetSize?: number): void {
127 const target = targetSize ?? Math.floor(this._objects.length / 2);
128
129 while (this._objects.length > target) {
130 const obj = this._objects.pop();
131 if (obj) {
132 obj.reset();
133 this._stats.size--;
134 }
135 }
136
137 this._updateMemoryUsage();
138 }
139
140 /**
141 * 预填充池

Callers 4

setMaxSizeMethod · 0.95
compactAllPoolsMethod · 0.45
compactAllPoolsMethod · 0.45

Calls 3

_updateMemoryUsageMethod · 0.95
popMethod · 0.80
resetMethod · 0.65

Tested by

no test coverage detected