What is Memory Leak? How can We Avoid?

<p>Inadequate memory management usually doesn&rsquo;t have dramatic consequences when dealing with &ldquo;outdated&rdquo; web pages. As the user navigates through links and loads new pages, the page information is removed from memory on each load.</p> <p>The rise of SPA (Single Page Application) encourages us to pay more attention to memory-related JavaScript coding practices. As the application consumes more and more memory, it can severely degrade performance and even cause the browser tab to hang.</p> <p>In this article, we&rsquo;ll explore programming patterns that cause memory leaks in JavaScript and explain how to improve memory management.</p> <p><strong>Read Also :&nbsp;</strong><a href="https://www.yourquorum.com/question/what-are-interview-questions-for-javascript?utm_source=medium_sh&amp;utm_medium=medium_sh&amp;utm_campaign=medium_sh" rel="noopener ugc nofollow" target="_blank"><strong>Top Qualifying Interview Questions For JavaScript</strong></a></p> <h1>What Is a Memory Leak and How to Spot It?</h1> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:650/0*yyMUro0rbBqsV5M3.jpeg" style="height:400px; width:650px" /></p> <p>Objects are kept in memory by the browser on the heap, while being accessible from the root directory through the reference string. Garbage Collector is a background process in the engine JavaScript that identifies inaccessible objects and deletes and restores the underlying storage.</p> <p>A memory leak occurs when an object in memory intended to be cleaned up in a garbage collection cycle is accessed from root through a reference unintended by another remaining object. Keeping redundant objects in memory causes excessive memory usage in the application and can lead to degraded and poor performance.</p> <p><a href="https://emma-delaney.medium.com/what-is-memory-leak-how-can-we-avoid-de11cedf9fb6">Website</a></p>
Tags: Memory Leak Avoid