Bug 506863 - On a 15.6GiB RAM system, kwin will crash with out of memory even when more than 8GiB is free when overcomitting is disabled
Summary: On a 15.6GiB RAM system, kwin will crash with out of memory even when more th...
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 6.4.2
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-10 13:44 UTC by Ellie
Modified: 2025-07-10 14:41 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ellie 2025-07-10 13:44:14 UTC
SUMMARY

On a 15.6GiB RAM system, kwin will crash with out of memory even when more than 8GiB is free when overcommitting is disabled, with kernel log messages like these:

[ 6219.447523] __vm_enough_memory: pid: 5777, comm: kwin_wayland, bytes: 3739648 not enough memory for the allocation

I understand that disabling overcommitting memory has inherent limitations in particular when it comes to using fork() instead of vfork(). However, I wanted to leave this here in case there is some obvious low hanging fruit on how to improve this. Disabling overcommitting can be useful as a protective measure for some processes from others and to enable programs capable of recovering from failed allocations to do so, I recognize almost nobody uses this but it would still be neat if it worked. Also, I distinctly remember not having this issue quite a while ago when testing out this kernel mode, so this might be a regression of some sort.

Perhaps kwin is mmap()ing some huge files or should be using vfork() in an obvious place?

My apologies if this ticket isn't useful.

STEPS TO REPRODUCE

1. Disable overcommitting RAM on a ~16GB RAM system
2. Do light usage with roughly 3GiB RAM taken.
3. It seems like kwin_wayland will eventually crash.

OBSERVED RESULT

Even with plenty of memory free, kwin seems to do something that requires a relatively giant allocation (even if not actually written into and therefore not actually reserved with overcommitting disabled) when perhaps that might be avoidable.

EXPECTED RESULT

It would be nice if kwin somewhat worked with overcommitting disabled, at least under such low RAM usage.

SOFTWARE/OS VERSIONS

Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: postmarketOS EDge
KDE Plasma Version: 6.4.2
KDE Frameworks Version: 6.15.0
Qt Version: 6.8.3

ADDITIONAL INFORMATION
Comment 1 Ellie 2025-07-10 14:23:33 UTC
Actually, it seems like I misread and it's trying to allocate 3MiB and not 3GiB. In that case it's probably just a victim of some other program, my bad. I guess the htop display might not be very correct when it comes to overcommitting disabled, or perhaps this is some VRAM issue. Closing for now, and my apologies (feel free to correct me if this ticket is actually useful).
Comment 2 Ellie 2025-07-10 14:41:32 UTC
Interestingly, after some more experimenting, it seems like plasma desktop might be a part of the problem somehow. With plasma mobile, I'm having way less issues even though I'm launching the same programs. I'm not sure yet why that is...