* @zh 释放隔离域 * @en Dispose the realm * * @zh 完全清理所有资源。释放后隔离域不可再使用。 * @en Completely clean up all resources. Realm cannot be used after disposal.
()
| 586 | * @en Completely clean up all resources. Realm cannot be used after disposal. |
| 587 | */ |
| 588 | dispose(): void { |
| 589 | if (this._disposed) { |
| 590 | return; |
| 591 | } |
| 592 | |
| 593 | // 移除所有系统 | Remove all systems |
| 594 | for (const info of this._systems) { |
| 595 | try { |
| 596 | info.scene.removeSystem(info.instance); |
| 597 | } catch { |
| 598 | // 忽略错误 | Ignore errors |
| 599 | } |
| 600 | } |
| 601 | this._systems = []; |
| 602 | |
| 603 | // 清除组件 | Clear components |
| 604 | this._components.clear(); |
| 605 | this._componentRegistry.reset(); |
| 606 | |
| 607 | // 清除服务 | Clear services |
| 608 | this._serviceRegistry.dispose(); |
| 609 | |
| 610 | this._disposed = true; |
| 611 | logger.info('UserCodeRealm disposed'); |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * @zh 检查是否已释放 |
nothing calls this directly
no test coverage detected