diff --git a/frontend/src/contexts/FileContext.tsx b/frontend/src/contexts/FileContext.tsx index c49a43e38..953c7720f 100644 --- a/frontend/src/contexts/FileContext.tsx +++ b/frontend/src/contexts/FileContext.tsx @@ -460,9 +460,8 @@ export function FileContextProvider({ thumbnailGenerationService.destroy(); // Force garbage collection hint - if (typeof window !== 'undefined' && window.gc) { - let gc = window.gc - setTimeout(() => gc(), 100); + if (typeof window !== 'undefined') { + setTimeout(() => window.gc && window.gc(), 100); } } catch (error) { @@ -597,10 +596,9 @@ export function FileContextProvider({ dispatch({ type: 'SET_CURRENT_MODE', payload: mode }); if (state.currentMode !== mode && state.activeFiles.length > 0) { - if (window.requestIdleCallback && typeof window !== 'undefined' && window.gc) { - let gc = window.gc; + if (window.requestIdleCallback && typeof window !== 'undefined') { window.requestIdleCallback(() => { - gc(); + window.gc && window.gc(); }, { timeout: 5000 }); } } @@ -612,10 +610,9 @@ export function FileContextProvider({ dispatch({ type: 'SET_CURRENT_VIEW', payload: view }); if (state.currentView !== view && state.activeFiles.length > 0) { - if (window.requestIdleCallback && typeof window !== 'undefined' && window.gc) { - let gc = window.gc; + if (window.requestIdleCallback && typeof window !== 'undefined') { window.requestIdleCallback(() => { - gc(); + window.gc && window.gc(); }, { timeout: 5000 }); } } diff --git a/frontend/src/services/enhancedPDFProcessingService.ts b/frontend/src/services/enhancedPDFProcessingService.ts index aa7802084..64bf69b8a 100644 --- a/frontend/src/services/enhancedPDFProcessingService.ts +++ b/frontend/src/services/enhancedPDFProcessingService.ts @@ -519,9 +519,8 @@ export class EnhancedPDFProcessingService { this.notifyListeners(); // Force memory cleanup hint - if (typeof window !== 'undefined' && window.gc) { - let gc = window.gc; - setTimeout(() => gc(), 100); + if (typeof window !== 'undefined') { + setTimeout(() => window.gc && window.gc(), 100); } }