elementary / applications-menu

Applications Menu for elementary OS and the Pantheon desktop environment
https://elementary.io
GNU General Public License v3.0
103 stars 35 forks source link

By opening Applications Menu, Wingpanel begin to use too much memory #117

Closed ryonakano closed 4 years ago

ryonakano commented 6 years ago

screenshot from 2018-07-14 15-52-37

By opening Applications Menu, Wingpanel begin to use too much memory on a system with LibreOffice.

Steps to reproduce the behavior

  1. Prepare a fresh install Juno Beta1 and update the system
  2. Run sudo apt install libreoffice
  3. Open Applications menu
  4. Wingpanel began to use over 200MB memory (in usual it spends only around 10MB memory)

Opening another indicator happens nothing. Only by opening Applications Menu.

I'm not sure this issue is due to either Wingpanel, Applications Menu, or LibreOffice.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/60875853-by-opening-applications-menu-wingpanel-begin-to-use-too-much-memory?utm_campaign=plugin&utm_content=tracker%2F62023936&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F62023936&utm_medium=issues&utm_source=github).
peteruithoven commented 6 years ago

TL;DR: The libreoffice icons cause a lot of memory usage after they've been loaded.

I've noticed some switchboard plug's execute some logic. They are included to enable settings search (switchboard-plugin). Also see: https://github.com/elementary/applications-menu/issues/83 It might be interesting to disable some plugins and compare the effect.

Is the memory usage only higher while the Applications menu is open or does it remain high after it's been opened once?

I can reproduce the issue, but I have to visit a page with the libreoffice icons. 33MB to 60MB without libreoffice. After installing it starts at 33MB. After opening it it goes to 62MB. But when I then visit the Office category (where the icons of Libreoffice are) it jumps to 221MB. I don't have a custom ppa for libreoffice. There is no issue when installing Libreoffice through flatpak.

If you want to test this, you can restart Winganel by running killall wingpanel.

peteruithoven commented 6 years ago

According to David Hewitt we might be able to track this down with Valgrind or Heaptrack.

ryonakano commented 6 years ago

@peteruithoven Thank you for your comment.

Is the memory usage only higher while the Applications menu is open or does it remain high after it's been opened once?

It remain high after it's been opened once, unless I killall Wingpanel.

FYI, I'm using Juno (not beta). I installed LibreOffice 6.0.6 from apt, and didn't add custom ppa for LibreOffice, too.

peteruithoven commented 6 years ago

Checking the icon info in Granite.AsyncImage: https://github.com/elementary/granite/blob/master/lib/Widgets/AsyncImage.vala#L319 (which is used to load the icon images) I can confirm svg versions of the icons are loaded. For example: /usr/share/icons/gnome/scalable/apps/libreoffice-writer.svg (which symlinks to /usr/share/icons/hicolor/scalable/apps/libreoffice-writer.svg)

Omg, libreoffice-calc.svg is 1.3MB!

/usr/share/icons/hicolor/scalable/apps$ ll -h | grep libreoffice
-rw-r--r--  1 root root 465K aug 30 11:49 libreoffice-base.svg
-rw-r--r--  1 root root 1,3M aug 30 11:49 libreoffice-calc.svg
-rw-r--r--  1 root root 624K aug 30 11:49 libreoffice-draw.svg
-rw-r--r--  1 root root 550K aug 30 11:49 libreoffice-impress.svg
-rw-r--r--  1 root root 142K aug 30 11:49 libreoffice-main.svg
-rw-r--r--  1 root root 659K aug 30 11:49 libreoffice-math.svg
-rw-r--r--  1 root root 142K aug 30 11:49 libreoffice-startcenter.svg
-rw-r--r--  1 root root 534K aug 30 11:49 libreoffice-writer.svg

Compare that to the icons that I use for my Resizer app:

-rw-r--r-- 1 peteruithoven peteruithoven  53K feb  9  2018 128.svg
-rw-r--r-- 1 peteruithoven peteruithoven  14K feb  9  2018 16.svg
-rw-r--r-- 1 peteruithoven peteruithoven  38K feb  9  2018 24.svg
-rw-r--r-- 1 peteruithoven peteruithoven  38K feb  9  2018 32.svg
-rw-r--r-- 1 peteruithoven peteruithoven  37K feb  9  2018 48.svg
-rw-r--r-- 1 peteruithoven peteruithoven  47K feb  9  2018 64.svg

There is a flag to disable svg's in general, but we use svg's for icon's a lot, so that's really not an option.

peteruithoven commented 6 years ago

Looks like there is a fixed & relevant Libreoffice issue: https://bugs.documentfoundation.org/show_bug.cgi?id=98141

peteruithoven commented 6 years ago

TL:DR: load_icon_async is causing huge memory leak?

If I don't load icons by commenting: https://github.com/elementary/granite/blob/master/lib/Widgets/AsyncImage.vala#L326-L337 the memory usage remains somewhere between 37 - 44MB.

If I just disable creating the surface and caching: https://github.com/elementary/granite/blob/master/lib/Widgets/AsyncImage.vala#L333-L337 it still sky rockets to 200MB+, which seems like a huge memory leak?

If I use the load_icon instead of load_icon_async here: https://github.com/elementary/granite/blob/master/lib/Widgets/AsyncImage.vala#L330 the memory usage only goes up to 62MB.

peteruithoven commented 6 years ago

I opened a Granite issue: https://github.com/elementary/granite/issues/223

ryonakano commented 4 years ago

I can no longer reproduce this issue on Odin Daily. Wingpanel only consumes around 10 MB on init and around 20 MB after opening it. Closing.