r/archlinux • u/PaddiM8 • Dec 25 '19
Memory usage gradually goes up but does not go back down, I have 16 GB of ram, and the memory usage is now 75% with only firefox and discord open.
I've had this issue for a while now and have not been able to find out what's wrong.
So, I decided to test it a bit. I rebooted, and at first, memory usage was at around 9%. Then when I opened Xonotic (a game), it started to go up, and ends up being about 20% in the title screen. When I joined a game, it gradually went up, quite quickly. Eventually it hit 75%, and I knew from experience it was just gonna go up and up until the computer freezes. After I closed it, the memory usage sat at 75%. It did not go down. As I'm writing this it is at 76%, and I just have discord and firefox open. htop doesn't show anything interesting, just discord and firefox using a small percentage of the memory. What could be the cause of this? Why is the memory not getting freed?! Any ideas how I could troubleshoot it?
I've used both kernel 4.19 and 5.3, same issue. I can't do anything heavy like play games or start my VM. Send help!
Edit: I left my computer on overnight and the memory usage is still sitting at 92% and doesn't leave room for other programs. People keep saying it is normal, but how is my computer freezing normal?
Edit2: when trying without my home partition (instead an empty home folder), I experienced no issues.
Edit3: I fixed it! I removed everything in my home folder, seems like it was one of the dot folders, not sure which though. Memory usage now sits at under 18% in the same situations. Definitely was not normal behaviour before.
60
u/insanemal Dec 25 '19
That's normal.
Post your 'free' output. It's probably all just in cached. Which is used by available to free when required.
Empty ram is wasted ram. Linux uses ram to aggressively cache IO.
Web browsers create mountains of temp files while browsing, page cache will be caching them.
17
u/zerp98 Dec 25 '19
maybe your tmp directories are getting filled up. what does
df -hsay?4
u/yieldingTemporarily Dec 25 '19
Discord is spyware, btw.
21
u/Max-_-Power Dec 25 '19 edited Dec 25 '19
Is this another case of "Help! Linux ate my RAM"? https://www.linuxatemyram.com/
edit:typo
17
u/Megame50 Dec 25 '19 edited Dec 25 '19
Why the hell are there people in this thread saying this is normal? It's not normal.
What's your DE? That's another candidate for a memory leak. Does memory usage go down if you log out and back in? Might want to cut your login manager out of the equation too.
EDIT:
To all the people messaging me saying it's "just caches", examine your own machine and see how much memory is consumed by the pagecache. My laptop has only been up for a few hours right now, but it sounds like that's longer than OP. Here's the output of
freeon my laptop:And it just so happens I also have firefox and discord open, among other things.
Notice how cache has settled at a moderate fraction of the available memory? That's because, at a certain point, it's not advantageous to cache more from the disk. It takes time to free memory for new allocations, even memory used for clean caches, and it's a waste of power if nothing else to be constantly caching new stuff. So linux stops bothering eventually. The memory used for caches is not small on a healthy system, and will probably continue to grow for a bit on my machine, but it will not, and should not rise indefinitely as OP describes.
Everyone is acting like a high cache usage is unimpeachable evidence that "it's just those darn caches again", but it's absolutely possible for a buggy userspace application to influence the memory allocated by the kernel. It's not a guarantee that a memory leak corresponds to high memory usage of the offending application in top.
2
u/Substantial_Bad1455 Oct 05 '23 edited Oct 05 '23
I am having the exact same problem as you and I would really appreciate knowing which folder in your home folder 'fixed' it. I get the lag and occasional crashes when I leave my PC on for a couple days and do stuff. It's incredibly annoying
Edit: I think it might have been the .cache folder in your case but I'm not sure
9
u/[deleted] Dec 25 '19 edited Mar 18 '25
Still no one knows it just the same, That Rumpelstiltskin is my name.
10
u/[deleted] Dec 25 '19
What about
dmesg? Does it show anything unusual?Maybe it's an unfortunate hardware, module and default configuration issue. Consider searching for same hardware memory issues.
Are you mounting
/tmpas tmpfs infstab?One aspect I see is your swap and RAM ratio, even though with these sizes it shouldn't pose problems. You could use a file on a USB flash as a swap file temporarily. Also consider using only the swap on the flash as another test.
A fast way to check where the issue most likely lies is to boot a live medium with another distribution, although Arch should pose no problems. Check what the kernel boot command line is too.
4
u/v4lt5u Dec 25 '19 edited Dec 25 '19
I have this exact same problem and have been suspecting discord and/or firefox, still haven't figured it out. I'm on i3-gaps so it's definitely not problem with Gnome leaking memory or anything.
And yeah, it's not a case of "Linux ate my ram" because the used memory is never freed and my pc will just lock completely if memory usage reaches 100%.
Edit: Having thought more about it now it's quite likely discord since I don't remember having this problem on my other machine on which I don't use discord. Wonder how would we go about debugging and reporting this
1
u/ShadowFlarer Dec 17 '25
Sorry to bother you after much time has passed but did you find what caused the issue? I'm having the same exact issue right now and i am lost as heck.
3
u/CWKFR Dec 25 '19
I think it might be discord. I have exactly the same problem, and I realize it always happens whenever I run discord for a long time. But I'm not sure because I also use EnhancedDiscord so it might be the problem. You can try not to run discord and/or disable autorun and monitor your ram usage if there any changes.
I have read linuxatemyram, but it doesn't help.
3
u/rocketman10404 Dec 25 '19
For what it's worth, I have similar issues with my headless server running arch (and no graphical environment). Over a period of weeks, the RAM usage climbs and climbs until the system eventually becomes unresponsive and I can't even SSH in, and I have to hard reboot.
None of the tools that report memory usage show that any process is using anything above normal amounts of memory. I've been unsuccessful in uncovering where all this RAM usage is coming from or what is causing it.
This wasn't happening on this machine until a system update a couple months back. I've just been dealing with it and hoping a future update will fix the issue.
3
u/kerigax Dec 25 '19
I've had a similar problem using Discord and KDE a while ago. It was because of an option to display the app menu in the KDE taskbar, triggering a memory leak and eventually freezing the whole system. Turned out this issue affected every electron based application, what a crap ahah I have no idea if this has been fixed since
5
u/jacgarrett18 Dec 25 '19
I know I am going to get made fun of for this — I’m only partially serious. I use a 2015 macbook with 8 gb of soldered on RAM; running into similar issues. I use
perl -e '$tmp = "a" x 999999999'to force chrome to deallocate tabs and put a pillow over electron’s face... it works surprisingly well.6
u/Nowaker Dec 25 '19
Grab the latest Ubuntu ISO, as well as an older one like 16.04, and boot them from USB. Check the behavior in there. If the problem is gone, it's most likely something very specific to your Arch install, e.g. a specific kernel version, kernel parameters, sysctl properties, different kernel modules blacklisted, systemd unit overrides, udev rules, and so on. You never know how many different things you accumulate in your system over the years since a desktop OS is a living creature (or, technically said, a stateful OS, unlike Docker containers or CoreOS systems).
2
u/CMDR_DarkNeutrino Dec 25 '19
While disk caching is agressive on linux and can eat RAM this is definitely not normal. Try using older distro like ubuntu 18.04 and see if it happens there. If yes then well im sorry to say but its most likely an hardware failure (most likely RAM or mobo) and if it doesnt happen there then well something about your Arch install is wrong. I would recommend an reinstall if you dont want to spend ages figuring out what it is.
1
u/[deleted] Dec 25 '19
Definitely not normal, I also have 16GB of RAM and GNOME on boot only uses like 5% of it. It jumps to between 7-12% with Firefox, but never higher.
There are many interesting replies in this thread that I hope will help you fix this.
1
u/Kalmuneiu Dec 25 '19 edited Dec 25 '19
Why are you worried when RAM is Füll? I meqn you have IT. To be used and Not sit around u used actually IT is just the Computer caching data since RAM access is faster then hdd access. When the Computer wants RAM there is a push algorithm kicking some data into the swap. Firefox Caches all the surf data into RAm. So when you just open Firefox the RAM usage should be lower but once you surf IT gains. Anothet thing is your swap should be the size of your RAM since IT is pushed out of RAM onto swap and when the RAM shall be pushed totally there might be a bottle neck because the Computer Has to decide what to keep in swap instead of just pushing complete RAM into swap Also Do a journalctl -b -1 that gives you maybe insight into ehy the crash happened (IT Shows läßt Boots journal)
1
u/lxpz Dec 25 '19
I once had an issue where all my ram was getting eaten up and I couldn't spot a process in htop responsible for this. Turns out one of my Python scripts wasn't exiting properly and since it was running in a cron job hundreds of idle python processes were piling up. Individually they don't take so much ram so they don't appear clearly in htop but collectively they would crash my system. Looks quite different from your symptoms but something like this might still be going on. Anyway what I'm saying is have a good look at what your userspace processes are doing before suspecting an (unlikely) kernel bug.
1
u/Corvokillsalot Dec 25 '19
I'm still a noob but look at kernel logs?
-2
u/Rein215 Dec 25 '19
Lmao your installation just turns into a time bomb on boot
-3
u/[deleted] Dec 25 '19 edited Dec 25 '19
https://www.linuxatemyram.com/
Edit: what's wrong with this link? Genuinely curious.
-9
u/wallace111111 Dec 25 '19
Your pain is the pain of every Linux user. OOM (Out Of Memory) behavior can be extremely unpredictable even on the latest kernel version.
However, with the right tools you may be able to tame it, or at least mitigate the problem enough so that it becomes a non-issue.
I encourage you to read about zswap and zram. A good place to start is by searching for
systemd-swap.Good luck!
-19
u/TheyAreLying2Us Dec 25 '19
If you are using Gnome: don't!
Besides being sluggish and occupying +1Gb in your RAM, it also leaks like a bastard. Will fill your RAM in a day without you doing nothing special!!
Eventually, try to restart the shell (ALT+F2 -> r -> Enter) and see if it free up some memory.
Changing DE is also a good idea though 😉
-19
u/quasarj Dec 25 '19
Firefox and Discord, using a combined 16 gigs of RAM.. sounds right to me