I've often wondered this. After a page refresh doesn't the browser throw everything away?
Thanks
It depends.
Some browsers, like Opera 12.17 and older, run in a single process.
These have a limited memory access, and do a bunch of stuff to the same address space.
Others, like Google Chrome, have a process per page and the process may be deleted after a refresh.
But, since it leaked, it may be outside the boundaries that the browser currently is controlling (e.g.: may be put in the swap).
There, there is no guarantee that it will be deleted.
Also notice that browsers may have bugs on the Garbage Collector and leave a few objects behind (like old IE versions).
This won't go away with a refresh.
Consider this very basic code:
var all = document.getElementsByTagName('*');
for(var i=all.length-1; i; i--)
{
all[i].parentNode.removeChild(all[i]);
}
document.write('<p>New content</p>');
all = document.getElementsByTagName('*');
On Google Chrome, open the 'Task Manager' (Menu > More Tools > Task Manager
).
Open a new tab and go to http://google.com and run the above code.
Keep an eye on the memory usage.
It should be around 25000kB.
Run this code.
You will notice that the memory will go up to around 40000kB.
Refresh and repeat.
Just watch how the memory usage goes up...
I would love to say "Yes", but browsers are very complex programs.
After a page refresh doesn't the browser throw everything away?
It should do, yes. So if your page has a memory leak, over time it will consume more and more memory until/unless the user refreshes it. (I have to refresh my Gmail tab every few days for exactly this reason.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With