Non-geek warning: This is an article about optimizations to the browser engine. It’s possible to read and understand, but it will get pretty technical. It basically says Opera developers have significantly reduced the memory usage when browsing websites, and plan to submit the improvements also to make all Blink-based browsers better.

Two weeks ago we released the beta version of Opera 39, and it is time to mention one of its improvements: heap compaction, an optimization pass for the Blink memory manager. It reduces memory usage by several megabytes per tab when browsing popular websites. Learn more about how we optimized memory usage in Opera.

Background: Memory fragmentation

Many users experience high memory usage, and one reason for that can be memory fragmentation, which happens when memory becomes a random sequence of differently sized chunks of used and unused memory. To put it simply, if you insert plates of different sizes haphazardly into a cupboard, it will be hard to use all the available space. If you stack them orderly, it will be more efficient, but it will also take more time to do so. And, since we put the plates (i.e., memory) in and remove them from the cupboard all the time, we unfortunately can’t spend much time on making it look pretty.

The same thing happens with the memory management.

To solve this, we have added a cleanup phase to the “plate” management inside Blink, which we call heap compaction. It reorders the memory to make use less RAM, make the future memory operations faster … and look pretty, too.

How we optimized memory usage in Opera

We attacked memory fragmentation by implementing a cheap, single-pass inplace compaction of heaps (picture a “heap” as the “cupboard” in the analogy above). The benefits are two-fold: less heap memory is allocated, and live objects are packed tighter, thereby increasing memory locality and speed of access.

How big are the memory savings

We conducted research to discover how heap compaction translates into memory savings. This involved visiting several popular websites, such as Wikipedia and NYTimes.com, as well as doing some occasional same-site navigation and interactions with the content. After approximately 15 minutes, we sampled the total heap size for the compactable sub-heaps.

The results show that, with this feature, the Blink heap size decreases significantly. As a very positive example, for Gmail compaction reduces the size from 6.8MB to 2.3MB, which, for many users, will translate into better general laptop performance. Heaps will naturally be compacted again as fragmentation regrows, throughout the lifetime of a site visit.

Opera’s engineers partner closely with our Google counterparts to reduce the memory use of the rendering engine Blink, and, in upcoming months, we are planning to upstream this technology to the the Blink project, as well.

Download Opera 39 beta and stay tuned for even more memory usage improvements we have in store for you.

The Opera Blink Team