Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome tab memory keeps growing, heap size stays the same

I'm working with a team on a single page application with quite a few timers, and about 10 REST API calls per second. We've used the Chrome memory profiling tools to locate all of our memory leaks--at this point the heap size stays about the same (i.e. in between garbage collections).

However, we're noticing that the longer the application runs, the more memory the Chrome tab itself uses. After a few hours, we've seen the tab memory grow to about 350MB, while the heap size remains at 6MB. If run overnight, the tab consumes over 500MB and becomes unusable by morning.

We need the application to run for long periods of time (we're hoping to restart it only once a week), so this is a problem.

Here's a screenshot of the heap timeline over the course of an hour. At the end, the tab's private memory size is 350MB, while the heap's size remained at around 5.4MB.

enter image description here

We've seen this in Chrome 40 and Chrome 38, on Windows 7. We have caching disabled, and are running the application in incognito mode.

Any idea why the tab memory size would grow to the point where Chrome is unusable, while the JS heap usage remains so small?

EDIT: We ran the app for a couple days and the tab memory size is up to 800MB, heap size still about the same.

EDIT (6/9/15): I'm not sure if this is documented anywhere, but it seems like Chrome changes the amount of memory it will allocate to a tab, based on the amount of free memory on the system. So, if you have a lot of free memory, tabs will use a lot of memory, and if you don't have much, it won't use as much. This doesn't seem to be proportional to heap size, it's probably just stuff that Chrome keeps around to make itself faster. This is only a theory, based on monitoring Chrome memory usage :)

like image 554
Cully Avatar asked Apr 09 '15 22:04

Cully


People also ask

Why do chrome tabs take up so much RAM?

Why is chrome this way slow? Using chrome can sometimes seems tedious, the reason behind this is as follows. Chrome splits every tab, plugin and extension into its own process. This leads to higher RAM usage since it has to duplicate some tasks for every tab.

Are chrome tabs stored in RAM?

Chrome, Firefox, Opera, and Microsoft Edge store every tab, plugin, and extension in a different RAM process. This process is called isolation and prevents one process from writing to another one. Hence, when you open your Task Manager or Activity Monitor, Google Chrome displays multiple entries.


1 Answers

This is probably too old and not relevant anymore, but for everyone else who experienced this: it's probably because of the opened dev tools. I had an application that would accumulate memory over time with the heap size staying the same, but when I closed the dev tools the memory went way down and didn't get back up like it did when dev tools was open. When profiling long term memory footprint, use chrome task manager first.

I can guess that in your case it happens because devtools has to store all those REST API calls (to show them in Network tab) and I'm not sure if chrome saves them to disk temporarily to save memory.

like image 185
Numbnut Avatar answered Oct 18 '22 19:10

Numbnut