brave / browser-laptop

[DEPRECATED] Please see https://github.com/brave/brave-browser for the current version of Brave
https://www.brave.com
Other
7.94k stars 974 forks source link

Reduce actual RAM usage #3836

Closed Bushido1 closed 6 years ago

Bushido1 commented 8 years ago

Did you search for similar issues before submitting this one? Yes.

Describe the issue you encountered: Brave takes about 170-210 Mb RAM (+Lastpass enabled) . For example, I use Opera with 2 extensions enabled and it takes about 130 Mb RAM,

Expected behavior: Brave should take half less RAM as it takes now. In most positive outcome, Brave should take less than 130 Mb RAM.

bbondy commented 8 years ago

Would you be able to compare the same use case on Chrome? Is it more similar to Opera?

Bushido1 commented 8 years ago

Chrome takes with the same 2 extensions about 141 Mb RAM.

bbondy commented 8 years ago

please stay 0.12.1 for now but just an fyi /cc @bridiver

Sh1d0w commented 8 years ago

I think there is memory leak somewhere. With continious usage for more than 16 hours after I closed most of the tabs opened and left only two of them, the main Brave process takes more than 700 MB RAM which is crazy:

On the topic under LInux (Fedora 24) on initial launch Brave takes 255 MB with no password extensions enabled.

Bushido1 commented 8 years ago

Now, if I opened Brave, then Task Manager showed that Brave takes on initial launch 291 Mb of RAM (Lastpass enabled).

bridiver commented 8 years ago

There is a known memory leak in the main process. It was mostly fixed and then accidentally re-introduced and now mostly fixed again in 0.12.1. The remaining leak is very small, happens less frequently and will be fixed soon. There were some renderer process memory leaks, but I believe those have all been addressed. @Bushido1, both Brave and Chrome run many different processes, which one(s) are you looking at? There is the main process (Brave) and the renderer processes (Brave Helper). There will typically be one renderer process for each main window and one renderer process per tab (just like Chrome), but in some cases multiple tabs will share a renderer process. There is also a renderer process for each extension that uses a background page (LastPass, Brave and PDFJS). Brave 0.12.0 and earlier also have an extra set of background page processes for each session tab. This is due to the fact that they are roughly the equivalent of having multiple accounts on Chrome, but in the next release they will be linked and share a single background process.

Bushido1 commented 8 years ago

I was summarizing all Brave processes that Task Manager showed me.

bridiver commented 8 years ago

I'm not sure about Opera, but in both Brave and Chrome the memory used by the main process is dwarfed by the memory used in the renderer processes. We are concerned about memory usage and want to keep it as low as possible, comparing the main process for Brave and Chrome is a bit like comparing apples and oranges. The renderer processes share most of the same code and should be roughly the same, but the main processes share basically nothing.

bridiver commented 8 years ago

you were only seeing 141MB total usage for Chrome for all processes? How many windows/tabs did you have open?

Bushido1 commented 8 years ago

5 These windows/tabs are opened for me during initial startup.

Bushido1 commented 8 years ago

This is latest Opera Developer version's RAM usage: 6

Bushido1 commented 8 years ago

This is latest Google Chrome stabel version's RAM usage: 7

Bushido1 commented 8 years ago

This is latest VIvaldi stabel version's RAM usage: 8

bridiver commented 8 years ago

Can you try this?

  1. Clear all tabs from Brave and Chrome so they start with a single empty tab
  2. Open cnn.com in one tab and facebook.com in a second tab I see roughly equivalent RAM usage on win7 between Brave and Chrome. Brave is still using slightly more, but the RAM usage for Chrome jumps quite a bit once I actually start using it.
Bushido1 commented 8 years ago

This is latest Mozilla Firefox stabel version's RAM usage: 9 This is latest Tor Browser stabel version's RAM usage: 10

Bushido1 commented 8 years ago

@bridiver Do you mean that browser should start with a single empty tab during initial start or after I have opened browser? Do you want that I should be logged-in to Facebook or not?

bridiver commented 8 years ago

when I tested each browser opened with a single empty tab. Another thing I just noticed is that you are using the 32-bit version of the other browsers. 64-bit apps will always consume more memory than the same app compiled for 32-bit because the pointers are twice as big (4 vs 8 bytes). It won't cause a doubling in the size because obviously not all memory is consumed by pointers, but it will make a noticeable difference. Try downloading https://www.google.com/intl/en/chrome/browser/desktop/index.html?platform=win64 and compare again

Bushido1 commented 8 years ago

Hopefully all my settings and bookmarks will be untouched after installing 64bit of Chrome to 32-bit. Is Brave 64-bit? (I think so, because Brave first page suggested my 64-bit version.)

bridiver commented 8 years ago

Brave is 64-bit. We have a 32-bit version, but you have the 64-bit version installed. You shouldn't lose any settings, but if you are concerned you can backup your chrome profile http://hellboundbloggers.com/2012/11/backup-restore-google-chrome-profile-50609/

Bushido1 commented 8 years ago

Chrome 64-bit: 5 Brave 64-bit: 6 These are with facebook.com (not logged in) and cnn.com Brave is still hogging much more RAM (Chrome till 350 Mb RAM, Brave more then 500 Mb RAM). I was wondering, why 32-bit browsers take less RAM and 64-bit browsers take more RAM in 64-bit Windows?

bridiver commented 8 years ago

The difference between the two is still more than than I'm seeing, but I'm testing on win7 so maybe that's why. I also have a fresh, blank profile for both Brave and Chrome. A difference of less than 200MB is not really a major cause for concern and the Brave main process is running node and has not been optimized for memory usage yet. I think this is likely just the result of loading unnecessary libs into the main process and will be easy to sort out either before 1.0 or shortly after it. The main process memory leak is a much bigger issue, but that should be mostly fixed in 0.12.1 and will definitely be fixed by 1.0. Thanks for the feedback @Bushido1 and we'll leave this ticket open to track the main process memory usage

Bushido1 commented 8 years ago

A difference of less than 200MB is not really a major cause for concern

For laptop users because of battery lasting, it is :)

bridiver commented 8 years ago

Applications use pointers to address locations in memory where data is stored. 64-bit apps can directly address a larger memory space, but that also means that the pointers to that space have to be larger to accommodate the extra addresses. It would be like the difference between a 5-digit telephone number and an 10-digit telephone number. A 5-digit telephone number would only allow 99,999 people to have their own phone numbers, but a 10-digit telephone number allows 9,999,999,999 to have their own numbers. However, the telephone numbers are now twice as long and therefore take twice as much space to store. The number of pointers in an application like Chrome or Brave is very large and therefore the total memory usage is higher.

Bushido1 commented 8 years ago

Thanks for explaining. So, sticking to 32-bit version is in nowadays technology clever idea if the main criterium is RAM usage.

bridiver commented 8 years ago

In terms of battery life, the amount of memory used by an application is normally not a real factor. CPU/GPU, display backlight and disk activity typically have the biggest impact on battery life. Your laptop has a fixed amount of RAM, but the OS allows you to use open more applications than your physical ram would allow by temporarily writing some of it to disk. The OS tries not to write frequently used memory to disk, but in some cases it is unavoidable and this can result in excessive disk activity and very poor performance. The OS will even actively kill some applications to restore performance when memory pressure is too high. In normal usage with a lot of tabs and windows open both Brave and Chrome will use significantly more than 200MB of RAM and since most of the extra RAM in Brave is likely going unused it will be written to disk once and become a non-issue.

bridiver commented 8 years ago

I'm not suggesting that we won't improve the memory usage, but if battery life is your real concern it should be a big issue.

Bushido1 commented 8 years ago

I use f.lux and Windows own screen brightness adjustament tool to keep the display backlight as low as possible. My RAM has not over exceeded during web browsing but I have noticed that Opera browser gets slower in certain forum pages if those pages are opened as a tab for a long time (about 1-2 hours) and these tabs are not refreshed nor I have not redirected to forums subpages in these tabs. But if I open a new tab and surf in a new website, then browsing in it is faster. I have not restarted browser or closed tabs with a slow browsing activity during that time but it feels strange to me that browser can operate with a few slowly browsing tabs and with tabs, where I it is possible to surf with a normal speed.

bridiver commented 8 years ago

we want to have equal or better memory usage compared to Chrome regardless of extensions, but to be a completely fair comparison you should install Chrome extensions for ad blocking and https everywhere. I doubt that will bridge the memory gap completely, but they are baked into Brave.

Bushido1 commented 8 years ago

Well, I use for ad blocking a separate program (Adguard for Windows with no browser extension). It uses about 40 Mb of RAM.

bridiver commented 8 years ago

@Bushido1 sometimes the page itself can cause issues that the browser can't really do anything about. This is a contrived example, but a web page could create an empty list in javascript and add a unique string to it every second and then search the list for a random entry. Over time the memory usage will grow and the time to search the string will grow to the point where it will have a noticeable impact on the page performance.

srirambv commented 7 years ago

@bridiver There is still high memory usage on Brave with just one tab running. Below is the comparison between Chrome/Opera/Firefox/Vivaldi/Brave with just one tab running and no extensions installed. still Brave is high on memory

image

bridiver commented 7 years ago

@srirambv I'm not terribly concerned about 135MB of ram, but it would be a better comparison if all the browsers were on the same page because that can have a big effect on the memory usage for the renderer

bbondy commented 7 years ago

when doing side by side comparisons, best to ensure it's the same number of tabs, same sites loaded, no extensions unless the check is related to that, fresh profile better unless the check is related to that.

Stryder24 commented 7 years ago

I am having what I consider a lot of memory used. I have 8 tabs open.

brave

Jacalz commented 7 years ago

Here is the detailed example that @bbondy was talking about: image This is Brave and Chrome running without any extensions, same pages and both are running fresh profiles!!! The difference is huge and this really needs to be improved :-1:

luixxiul commented 7 years ago

I don't think it's fair to compare Brave with adblocker, fingerprinting method protection, etc. with the clean Chrome :-D How much RAM will Chrome take after Adblock, ublock Origin and NoScript are installed and enabled?

Jacalz commented 7 years ago

Here is a comparison with Ublock0, Disconnect, HTTPSe and Privacy Badger on chrome vs Brave: image Still the very same story :-1: With new clean profiles :-1:

bridiver commented 7 years ago

The 77.8MB you are seeing is only the Chrome browser process and that is a drop in the bucket of the total RAM usage. You will find multiple process for both Chrome and Brave under "Background Processes" and it's not uncommon to have a single tab take up 400+MB of RAM. If you are doing anything more than a trivial test with a few tabs, the non-renderer processes will be completely lost in the noise of the RAM usage by the renderer processes.

ntolman commented 7 years ago

Here's the RAM usage on my system compared with Firefox. 2017-09-21

Here are all the extensions Firefox is using 2017-09-21 1

luixxiul commented 7 years ago

You will find multiple process for both Chrome and Brave under "Background Processes" and it's not uncommon to have a single tab take up 400+MB of RAM. If you are doing anything more than a trivial test with a few tabs, the non-renderer processes will be completely lost in the noise of the RAM usage by the renderer processes.

It seems to me to be worth blogging or tweeting about that, telling users pointless to do the simple math on Task Manager.

bsclifton commented 7 years ago

++ on a blog post or at least a wiki entry; would be great to know more information 😄 Would this be something you could consider doing, @bridiver?

NumDeP commented 6 years ago

Hi @bridiver I think this issue requires an investigation label before the wiki entry is made. I'm certainly not as experienced as you are but I have to disagree with that notion that it's not a huge concern because the above reports were mostly trivial tests to provide evidence and not necessarily normal usage and as you suggest 400+MB is not really uncommon but the following report certainly has to be.

I think this issue and the other issue pertaining to excessive energy drain/consumption in MacOS and recently Android platform are sort of linked and the below stats are quite possibly a plausible reason as to where the great energy drain is going which are being reported in the community and Github.

I realize the comparison to FF could be regarded as a caveat, due to Mozilla's recent introduction of Quantum which has surprisingly made it more efficient memory wise but not by this much.

FF Version 58.0.2 (64-bit)

Brave: 0.21.18
OS Architecture: x64
OS Platform: Linux

15 tabs and the same sites loaded in each finding, no apps/extensions with the exception of uBo in FF.

FF with fresh start                      - Around 519  MiB

Brave with fresh start                   - Around 444  MiB

FF with 15 sites                         - Around 1232 Mib

Brave without Strict Site Isolation      - Around 2857 Mib

Brave with Strict Site Isolation         - Around 2949 MiB

Brave starts with 75 MB less memory but uses 1625 MiB more memory than FF 

FF with fresh start
ff fresh start Brave with fresh start brave fresh start FF with 15 sites ff with 15 sites Brave without Strict Site Isolation brave without strict site isolation 15 sites Brave with Strict Site Isolation brave with strict site isolation 15 sites

bsclifton commented 6 years ago

Closing as we won't be able to make a meaningful impact with this code-base (Muon). Let's open an issue in the brave-core issue log if this occurs there

The latest developer channel release for brave-core can be downloaded here: https://brave.com/download-dev