1

My single-page web application runs into a memory leak situation with Chromium on Linux. My app fetches html markup and embeds it into the main page via .innerHTML. The remote html snippets may reference jpgs or pngs. The memory leak does not occur in JS-heap. This can be seen in the table below.

Column A shows the size of the JS-heap as reported by performance.memory.usedJSHeapSize. (I am running Chromium with -enable-precise-memory-info parameter to get precise values.)

Column B shows the total amount of memory occupied by Chromium as shown by top (only start and end values sampled).

Column C shows the amount of "available memory" in Linux as reported by /proc/meminfo.

       A              B               C
01  1337628        234.5 MB        522964 KB
02  1372198                        499404 KB
03  1500304                        499864 KB
04  1568540                        485476 KB
05  1651320                        478048 KB
06  1718846                        489684 KB GC
07  1300169                        450240 KB
08  1394914                        475624 KB
09  1462320                        472540 KB
10  1516964                        471064 KB
11  1644589                        459604 KB GC
12  1287521                        441532 KB
13  1446901                        449220 KB
14  1580417                        436504 KB
15  1690518                        457488 KB
16  1772467                        444216 KB GC
17  1261924                        418896 KB
18  1329657                        439252 KB
19  1403951                        436028 KB
20  1498403                        434292 KB
21  1607942                        429272 KB GC
22  1298138                        403828 KB
23  1402844                        412368 KB
24  1498350                        412560 KB
25  1570854                        409912 KB
26  1639122                        419268 KB
27  1715667                        399460 KB GC
28  1327934                        379188 KB
29  1438188                        417764 KB
30  1499364                        401160 KB
31  1646557                        406020 KB
32  1720947                        402000 KB GC
33  1369626        283.3 MB        378324 KB

While the JS-heap only alters between 1.3 MB and 1.8 MB during my 33-step test, Chromium memory (as reported by top) grows by 48.8 MB (from 234.5 MB to 283.3 MB). And according to /proc/meminfo the "available memory" is even shrinking by 145 MB (from 522964 KB to 378324 KB in column C) at the same time. I assume Chromium is occupying some good amount of cache memory outside of the reported 283.3 MB. Note that I am invoking GC manually 6 times via developer tools.

Before running the test, I have stopped all unnecessary services and killed all unneeded processes. No other code is doing any essential work in parallel. There are no browser extensions and no other open tabs.

The memory leak appears to be in native memory and probably involves the images being shown. They are never being freed, it seems. This issue appears to be similar to 1 (bugs.webkit.org). I have applied all the usual suggestions as listed here 2. If I keep the app running, the amount of memory occupied by Chromium will grow unbound up until everything comes to a crawl or until the Linux OOM killer strikes. The one thing I can do (before it is too late) is to switch the browser to a different URL. This will releases all native memory and I can then return to my app and continue with a completely fresh memory situation. But this is not a real solution.

Q: Can the native memory caches be freed in a more programatic way?

Timur
  • 11
  • 1
  • 1
    Best place to report bugs about a browser is [their bug tracker](https://crbug.com). – Kaiido Sep 08 '19 at 12:14
  • Such a fundamental issue and yet, it is stalled in the [Webkit bug tracker](https://bugs.webkit.org/show_bug.cgi?id=31253) for 10 years. How is this possible? – Timur Sep 08 '19 at 12:42

0 Answers0