Mozilla introduced Garbage Collection in Firefox 38 that improves memory management of the web browser as part of the organization's ongoing effort to bring memory usage of the browser down and optimize it as best as possible for all use cases.
So how does compacting work in Firefox?
Memory problems arise when many arenas with few live cells each exist as the space cannot be released to memory in this case, While "dead" cell space can be used by the same kind, they cannot be used by different kinds.
Mozilla's algorithm works by moving live cells between arenas to reduce the number of arenas used by the Heap. It works by selecting appropriate cells, moving them and updating all pointers to make sure no objects or data is lost in the process.
The selection process lists all arenas with live cells in decreasing order and splits it in half to move cells out of arenas with few cells to release them to memory afterwards.
It is interesting to note that compacting triggers only on three specific events currently:
Check how much memory free cells use
You can check how much memory cells use in Firefox.
Additional information about the process are available on Mozilla Hacks.
There is a imbalance currently in the reporting that covers Firefox and Mozilla. Feature removals and additions get lots of publicity, usually by Firefox users opposing the change, whereas core improvements like these, that are mostly under the hood, get little to no publicity at all.
Mozilla could do a better job at promoting those under the hood improvements as those are features that are -- usually - welcome by all users of the browser.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.