fix: 收敛战斗内存增长并强化战斗结束清理

This commit is contained in:
panw
2026-03-18 16:46:52 +08:00
parent 56227d8f3f
commit 035066752c
7 changed files with 155 additions and 58 deletions

View File

@@ -11,11 +11,34 @@ import { instantiate, Node, Prefab, Vec3 ,tween, v3,animation,Label,resources,Sp
export class Tooltip extends ecs.Entity {
/** 对象池 */
static pool: NodePool = new NodePool();
static readonly MAX_POOL_SIZE: number = 80;
/** 回收节点 */
static put(node: Node) {
if (!node || !node.isValid) return;
if (this.pool.size() >= this.MAX_POOL_SIZE) {
node.destroy();
return;
}
node.active = false;
node.parent = null;
this.pool.put(node);
}
static clearPool() {
while (this.pool.size() > 0) {
const node = this.pool.get();
if (node && node.isValid) {
node.destroy();
}
}
this.pool.clear();
}
static getPoolStats() {
return {
total: this.pool.size(),
max: this.MAX_POOL_SIZE
};
}
/** ---------- 数据层 ---------- */
// SkillModel!: SkillModelComp;