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

Method release

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

* 释放对象回池中 * @param obj 要释放的对象

(obj: T)

Source from the content-addressed store, hash-verified

82 * @param obj 要释放的对象
83 */
84 public release(obj: T): void {
85 if (!obj) return;
86
87 this._stats.totalReleased++;
88
89 // 如果池未满,将对象放回池中
90 if (this._stats.size < this._maxSize) {
91 // 重置对象状态
92 obj.reset();
93 this._objects.push(obj);
94 this._stats.size++;
95 this._updateMemoryUsage();
96 }
97 // 如果池已满,让对象被垃圾回收
98 }
99
100 /**
101 * 获取池统计信息

Callers 3

setAssetReferenceMethod · 0.45
onDestroyMethod · 0.45

Calls 3

_updateMemoryUsageMethod · 0.95
resetMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected