whois
This commit is contained in:
@@ -46,9 +46,12 @@ const memoryManager = {
|
||||
// 启动内存监控
|
||||
startMonitoring() {
|
||||
if (this.monitoring.enabled && performance && performance.memory) {
|
||||
setInterval(() => {
|
||||
this.checkMemoryUsage();
|
||||
}, 30000); // 每30秒检查一次
|
||||
this.memoryCheckInterval = setInterval(() => {
|
||||
// 只在页面可见时检查内存
|
||||
if (!document.hidden) {
|
||||
this.checkMemoryUsage();
|
||||
}
|
||||
}, 30000); // 每 30 秒检查一次
|
||||
}
|
||||
},
|
||||
|
||||
@@ -333,6 +336,10 @@ const memoryManager = {
|
||||
// 页面卸载时清理所有资源
|
||||
window.addEventListener('beforeunload', () => {
|
||||
this.cleanupAllResources();
|
||||
if (this.memoryCheckInterval) {
|
||||
clearInterval(this.memoryCheckInterval);
|
||||
this.memoryCheckInterval = null;
|
||||
}
|
||||
});
|
||||
|
||||
// 页面可见性变化时的处理
|
||||
@@ -341,6 +348,10 @@ const memoryManager = {
|
||||
// 页面隐藏时清理一些资源
|
||||
console.log('页面隐藏,清理资源...');
|
||||
this.cleanupCaches();
|
||||
} else {
|
||||
// 页面重新可见时触发一次内存检查
|
||||
console.log('页面重新可见,检查内存使用情况...');
|
||||
this.checkMemoryUsage();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user