elvetemedve / gnome-shell-extension-system-monitor

Gnome Shell extension for displaying resource usage
GNU General Public License v3.0
87 stars 15 forks source link

Possible memory leak #42

Open CubeTheThird opened 6 years ago

CubeTheThird commented 6 years ago

I've been experiencing memory issues with the gnome-shell process, reaching upwards of 1GB over time, and it appears to mostly occur when this extension is enabled (memory does increase without it, but not nearly to that degree). I don't know of a way to obtain memory usage statistics for a specific extension, but will provide logs/reports/etc with some guidance.

elvetemedve commented 6 years ago

As Gnome developers said, the Gnome Shell is single threaded, so you can't tell the memory usage of individual extensions externally (e.g. by top command).

The extension reads various files to compute the resource statistics. Each file has an object in the code, but it is re-used for each read operations. Previously there was a bug when a new file object is created before read operations.

CubeTheThird commented 6 years ago

Thank you for the information. To clarify, when you refer to a bug, is this in the extension, or in Gnome Shell itself?

elvetemedve commented 6 years ago

There was a fault in the extension.

I started to watch the gnome-shell process and I see that the used amount of RAM increases over time. So it looks like you are right about the memory leak. I will try to figure out what's wrong this week.

elvetemedve commented 6 years ago

@CubeTheThird Can you tell which version of Gnome do you have?

I did some experiment to find memory leaks in the extension code, but it seems like JS code itself is leaking memory. I replaced the statistic collecting part of the code by returning fake data, but the increasing memory usage still occurred. I haven't spotted any obvious bug in this simplified code.

However I accidentally spotted another memory leak. Here is how my tests scenario looked like:

The conslusion from this is that there must be a memory leak in Gnome Shell itself (or other components), since I managed to increase memory by using two Gnome made application without any extensions enabled. Similar bug is also reported upstream.

So I'm afraid that at the moment I can't do too much about fixing it.

CubeTheThird commented 6 years ago

I have the same versions for all applications as yourself, and I do indeed witness the memory leak as you describe. I do also feel that the rate at which the memory increases with this extension enabled is significantly higher, however it is indeed possible that this is caused by an issue with gnome-shell itself. I will notify if any changes occur with the latest version released on the Arch repositories, to which I have yet to update.

elvetemedve commented 6 years ago

There is a discussion going on about a Gnome Shell related bug. So far it confirmed my theory of something wrong with Javascript garbage collector.

elvetemedve commented 5 years ago

Memory usage has been improved since Gnome Shell 3.30.

@CubeTheThird Could you upgrade Gnome to 3.30.0 or later and do some testing to see if you still experience this problem? (As for me the gnome-shell process consumes around 130 MB of RAM after half a day of usage, which is very good.)

CubeTheThird commented 5 years ago

Thanks for the update. I've already upgraded Gnome Shell, so I will re-enable the extension and test.

CubeTheThird commented 5 years ago

While I haven't been taking detailed notes, there does still appear to be an increase in memory footprint. What I have also noticed though, and I am not familiar enough with the environment to know if it is coincidence, is that the memory usage seemed to have also increased with the extension disabled, though not uninstalled.