Memory management
Efficient memory management is crucial in SSR to prevent memory leaks and ensure optimal performance.
Avoid Long-Lived References
Ensure that server-side instances of your application do not hold onto references longer than necessary:
Dispose of Timers: Clear any timers (setTimeout
, setInterval
) once they're no longer needed.
setTimeout
, setInterval
) once they're no longer needed.Remove Event Listeners: Detach any event listeners added during rendering.
Avoid Modifying Global Prototypes
Never override or extend global prototypes (e.g., Array.prototype
) as it can lead to memory leaks and unpredictable behavior across different instances.
Use Weak References
When possible, use weak references to allow garbage collection of unused objects.
Last updated
Was this helpful?