Garbage Collection improvements in Firefox improve memory usage
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:
- When Firefox is running out of memory.
- When the operating system sends a "memory pressure" event.
- When the user has been inactive for a certain period of time (currently about 20 seconds)
Check how much memory free cells use
You can check how much memory cells use in Firefox.
- TypeÂ about:memory in the browser's address bar and hit enter.
- Search for js-main-runtime-gc-heap-committed
- Locate gc-things in its tree.
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.
Now read: Which Firefox features would you like to see removed, and which polished?
‘Improvements’ that ‘improve’.
Now that’s what I call improvement! :-)
I stopped using Java about 2 years ago, I run Windows 8.1, and found that the earlier Beta version was susceptible to crashes with Java. I must admit I have hardly missed it and have had, touch wood, no crashes since then.
Keep up the good work Martin, I love the site.
You can trigger compacting with this add-on.
I don’t know why I have the following problem with Firefox on my home system… but when I have left the computer idle for some time (10 mins?) I come back to a non-responding Firefox. I have to either restart it, or wait 20-30 secs before it responds.
This is wrong article and dumb.
Actually firefox is killing my PC memory (ver 39), earlier it was better.
While watching any video or movie, within 2mins reaching 3GB memory, and both PC and Firefox hanging/not responding.
What a waste update from firefox.
I often have troubles with new firefox
after updating v38. And now 40.0.3, too.
The thing happened:
(1)firefox goes into petit-freze very often.
(about 10 second a time)
when it happened, all firefox pages are freezed.
(2)firefox-icons on task-bar(windows7)
are shuffled suddenly.
(1)… it seems happen when firefox need
to allocate much memories.
example: opening a new heavy page
which has many pictures, flash-objects…
ajax gets pictures (ex: scrolling google map
watching video files)
(2)… it seems hapen when firefox returns from petit-freeze
it causes focus-shuffle ,too.
focused window disappears to back window ,
not focused window appears to front window.
so I lost the window which now I’m reading.
(by the way, I always open as a new window each web-site
substitute for a new tab.)
I guess that:
(1) the garbage collection algorithm is changed at v38.
(2) when firefox needs much memory ,
firefox uses the new garbage collection.
(3) the garbage collection causes aka “stop-the-world”
with every windows every tasks of firefox.
and it seems as “petit-freeze”.
(4) and the garbage collection causes…
restart some tasks or windows of firefox.
and “Windows-OS” may recognise that
the old-tasks are terminated
the restarted-tasks are apeared as new windows,
so new windows are appears on right-side of task-bar.
I wonder what and how garbage collection logic is changed.
I know that new logic is “Generational Garbage Collection” ,
which has better memory efficiency than old logic.
and how the logic is processed….like JavaVM.
But I didn’t think that the treatment for objects(variable,
arrays, strings, instances…) is not changed each logic.
A garbage collection logic does :
unyoking(flashing) disused memories for re-usable
coping and re-alligning objects into another memory
“Generational Garbage Collection” does it ,too.
(but the logic has some differences how to use of memory.
classifying objects as older or younger
so it is called “Generational…”)
I think each logic is same about memory-copy-process.
If the treat of memory has had changed,
it can cause these phenomenon.
But I have no idea what is the difference between
new and old logic / memory-treatment,
and what concern about tasks.
and why window-icons on task-bar are suffled.
Why petit-freeze became longer ?
…is it happen when the older-memoris are flashed ?
I would like the petit-freeze to become shorter a time,
and not to shuffle the icons on task-bar.
memory 4GB (Crhome runs lightly)
1TB hdd (not ssd)
by the way, firefox on ubuntu14.04 became slowly,too
like on Windows7. May be same reason.