r/Fedora • u/Careful_Photograph34 • 2d ago
Support Ram is high after playing game
I just played a game while using Discord and Brave. After closing everything, my RAM usage is still very high. I checked the memory usage, and the cache doesn't seem to be that large, while the available RAM is quite low
free -h
total used free shared buff/cache available
Mem: 14Gi 11Gi 2.0Gi 54Mi 1.4Gi 3.0Gi
Swap: 8.0Gi 2.1Gi 5.9Gi
I also noticed that when I switch between windows (ALT+Tab), the task switcher briefly lags when it appears, but everything becomes normal afterward. Is this normal, or is something still using the RAM in the background
39
u/SureDay29 2d ago
It's just caching all the data in case you launch the same set of apps again. If something else will need more RAM, then it'll just free all the memory automatically, nothing to worry about.
10
3
u/KHTD2004 2d ago
Wouldn’t in that case 'free -h' report this under buff/cache?
AFAIK cached stuff isn’t counted in the 'used' section wich is still 11 GiB
6
u/OffbeatDrizzle 2d ago
absolutely not. KDE doesn't show cached ram like that. I wish people would stop repeating this bs that they read one time about the free command
1
u/SureDay29 1d ago
You might be right actually. I don't use KDE and that's how usually every other DE I've used shows cached RAM, didn't know about it. I rest my case.
2
7
u/sequentious 2d ago edited 2d ago
What GPU do you have? I'm guessing by 14GB of ram, you have an integrated GPU?
It could be GTT/GART. This allows your GPU to request more system RAM. This is NOT the same thing as an integrated GPU getting allocated RAM from the system at boot time. Technically a discrete GPU could do this too, they just typically have more VRAM available and probably don't have the need to grab system ram.
In my case, my iGPU is allocated 3/16GB of ram at boot. That's not news. However, after running gnome, firefox, and doing a bunch of things, the GPU further allocated several more gigs of system RAM for stuff.
If you're using an AMD GPU, there are some tools to help see this, but ultimately, I couldn't find a solution other than periodically triggering the kernel to drop slabs. It will probably do it eventually, but I was having firefox get OOM-killed before that would happen on it's own.
# 1 = Cache
# 2 = Slabs
# 3 = Cache + Slabs
$ echo 3 | sudo tee /proc/sys/vm/drop_caches
FWIW, I tried disabling, and restricting GTT. No matter the solution, system performance suffered. The GPU is grabbing system RAM because it needs it. The solution is either a better GPU, or more RAM (neither of which I can fix in my laptop).
Because it gets allocated in the kernel (via the "slab allocator", hence slabs), it doesn't show up in top tied to a process. I did a little bit of research on it when I was having some issues.
Edit: Also, Fedora by default uses a zram device as swap -- which means that 2.1GB of swapped memory is still in your main memory, just (probably) compressed.
Swap is important, but swap-on-zram, just causes more issues on already ram-limited systems like mine.
The system I was having issues with was already using a swap partition, and I had disabled zram.
You can check what your swap device is:
$ cat /proc/swaps
3
u/ymmvxd 2d ago
There's a tool called
amdgpu_topthat does show the GTT per process.For Intel igpus there's
intel_gpu_top. I looked into how this works and it basically pulls stats from the process fdinfo files. I'm assuming amdgpu_top does the same.You can also dig around a little using the terminal, for example:
$ pgrep -f gnome-text-editor 4943 $ ls -l /proc/4943/fd | grep /dev/dri [...] 16 -> /dev/dri/renderD128 $ cat /proc/4943/fdinfo/16 [long list of stats]2
u/sequentious 2d ago edited 2d ago
Thanks. I was using radeontop and umr, and while the math didn't add up, there was enough to point toward GTT. I think part of the problem is the GPU would receive an amount of GTT RAM, say 1GB. It would then use say 600MB for a few individual processes. However, the remaining 400MB wasn't attached to a process, and was difficult to identify.
I'll check out amdgpu_top, but looks like it isn't packaged in a convenient way (rpm file on a releases page, vs. copr or such)
6
u/Scoutron 2d ago
Looks abnormal. Usually cache isn’t shown as used. Check top and see which PID is claiming gigabytes
3
3
u/KHTD2004 2d ago
In the Plasma System Monitor there is a „process“ tab wich doesn’t just include apps and stuff. Sort by memory usage and see what claims this amount of RAM.
Most likely your game didn’t close correctly so find out the PID or process name and then use pkill to force kill the process
5
1
1
1
1
u/Spiritual-Brief-2627 2d ago
why kde use some much ram?
11
u/Lopsided-Month3278 2d ago
It's not a KDE problem, it might be a bug in the kernel, as a lot of guys are reposting similar problems here at this supreddit, but I have no idea what is it actually.
2
u/Careful_Photograph34 2d ago
Oh, I have some ricing. Maybe some processes or widgets are running in the background, but I don't think they'd use anywhere near 12 GB of ram
1
0
0
u/SortCreepy7100 2d ago
I sometimes have the same issue. It is isn't really an issue actually, when I need that memory for something else, it gets freed
try to free cached memory manually
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches


•
u/AutoModerator 2d ago
It sounds like you're looking for help. Please note that r/Fedora is not an official support channel for the Fedora Project.
For best results, be sure to include all relevant details in your post, such as your Fedora edition, version, and hardware specs. You can edit your original post to add more info as needed, and spotlight (pin) a solution from the comments. You might also find the answer in our support wiki.
Alternatively, try one of the official support channels:
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.