Garbage Collection Algorithm — Mark & Sweep
https://medium.com/@animeshgaitonde/garbage-collection-algorithm-mark-sweep-ed874272702d
BackgroundA software application generally needs to allocate resources (i.e memory, database connection, socket, file handle, etc) when it runs in the memory. It requests these resources from Operating System, which is responsible for managing these resources. Once the application is done with an allocated resource, its essential that the same is released back to the Operating System.
For instance if there is a program which uses a Linked List to store data should release the memory allocated dynamically when a node is deleted from it. If the memory is not released it results in a memory leak and thereby resource wastage. We’ll see with a real world example how it results in resource wastage & can lead to performance issues when the application keeps on allocating memory but doesn’t release it once its done with it.