How to reduce OOM score for X11 with systemd
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
When my PC runs out of memory, the Linux OOM killer likes to kill Xorg first rather than the actual app using a lot of memory, which for the most part takes down the whole system (killing all my apps instead of just the one with the bad memory leak.)
It is my understanding that I can avoid this by setting the OOM-killer score for X11 to a very low value, such as -900
, so that the kernel OOM killer will try to end other tasks first, making it much more likely to kill a bad application instead of the whole windowing environment.
However I can't see how to do this with systemd
. Apparently there is an OOMScoreAdjust option you can set in a .service
file, except 1) I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade) and 2) I can't even find the one for X-Windows. I only have a display-manager.service
which points to lightdm
.
How might one tell systemd
to adjust the OOM score for Xorg? I am using Arch Linux, although I believe they don't make many/any changes to systemd
.
systemd xorg out-of-memory
 |Â
show 3 more comments
up vote
2
down vote
favorite
When my PC runs out of memory, the Linux OOM killer likes to kill Xorg first rather than the actual app using a lot of memory, which for the most part takes down the whole system (killing all my apps instead of just the one with the bad memory leak.)
It is my understanding that I can avoid this by setting the OOM-killer score for X11 to a very low value, such as -900
, so that the kernel OOM killer will try to end other tasks first, making it much more likely to kill a bad application instead of the whole windowing environment.
However I can't see how to do this with systemd
. Apparently there is an OOMScoreAdjust option you can set in a .service
file, except 1) I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade) and 2) I can't even find the one for X-Windows. I only have a display-manager.service
which points to lightdm
.
How might one tell systemd
to adjust the OOM score for Xorg? I am using Arch Linux, although I believe they don't make many/any changes to systemd
.
systemd xorg out-of-memory
2
"I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade)" ... which is why you havesystemd edit
, which will create a override file in/etc
which will be unaffected by package upgrades. That said, there won't be a service for X, since it is started and managed by your display manager, which seems to be LightDM.
â muru
May 18 at 7:15
Aha, didn't know about that, thanks! Assume you meansystemctl edit
.
â Malvineous
May 18 at 7:18
Yes, sorry,systemctl edit
.
â muru
May 18 at 7:20
Have you considered adding more swap?
â Mark Stosberg
May 18 at 12:23
1
systemd won't start X. it will start a display manager: gdm, kdm, lightdm, ... . This one in turn will start X. So the change should be done in the display manager related config. For example in lightdm.conf there's this handy (commented) entry calledxserver-command =
. put a wrapper to Xorg (or to Xorg's own wrapper...) there
â A.B
May 19 at 18:06
 |Â
show 3 more comments
up vote
2
down vote
favorite
up vote
2
down vote
favorite
When my PC runs out of memory, the Linux OOM killer likes to kill Xorg first rather than the actual app using a lot of memory, which for the most part takes down the whole system (killing all my apps instead of just the one with the bad memory leak.)
It is my understanding that I can avoid this by setting the OOM-killer score for X11 to a very low value, such as -900
, so that the kernel OOM killer will try to end other tasks first, making it much more likely to kill a bad application instead of the whole windowing environment.
However I can't see how to do this with systemd
. Apparently there is an OOMScoreAdjust option you can set in a .service
file, except 1) I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade) and 2) I can't even find the one for X-Windows. I only have a display-manager.service
which points to lightdm
.
How might one tell systemd
to adjust the OOM score for Xorg? I am using Arch Linux, although I believe they don't make many/any changes to systemd
.
systemd xorg out-of-memory
When my PC runs out of memory, the Linux OOM killer likes to kill Xorg first rather than the actual app using a lot of memory, which for the most part takes down the whole system (killing all my apps instead of just the one with the bad memory leak.)
It is my understanding that I can avoid this by setting the OOM-killer score for X11 to a very low value, such as -900
, so that the kernel OOM killer will try to end other tasks first, making it much more likely to kill a bad application instead of the whole windowing environment.
However I can't see how to do this with systemd
. Apparently there is an OOMScoreAdjust option you can set in a .service
file, except 1) I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade) and 2) I can't even find the one for X-Windows. I only have a display-manager.service
which points to lightdm
.
How might one tell systemd
to adjust the OOM score for Xorg? I am using Arch Linux, although I believe they don't make many/any changes to systemd
.
systemd xorg out-of-memory
edited May 18 at 8:09
asked May 18 at 7:13
Malvineous
1,70111332
1,70111332
2
"I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade)" ... which is why you havesystemd edit
, which will create a override file in/etc
which will be unaffected by package upgrades. That said, there won't be a service for X, since it is started and managed by your display manager, which seems to be LightDM.
â muru
May 18 at 7:15
Aha, didn't know about that, thanks! Assume you meansystemctl edit
.
â Malvineous
May 18 at 7:18
Yes, sorry,systemctl edit
.
â muru
May 18 at 7:20
Have you considered adding more swap?
â Mark Stosberg
May 18 at 12:23
1
systemd won't start X. it will start a display manager: gdm, kdm, lightdm, ... . This one in turn will start X. So the change should be done in the display manager related config. For example in lightdm.conf there's this handy (commented) entry calledxserver-command =
. put a wrapper to Xorg (or to Xorg's own wrapper...) there
â A.B
May 19 at 18:06
 |Â
show 3 more comments
2
"I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade)" ... which is why you havesystemd edit
, which will create a override file in/etc
which will be unaffected by package upgrades. That said, there won't be a service for X, since it is started and managed by your display manager, which seems to be LightDM.
â muru
May 18 at 7:15
Aha, didn't know about that, thanks! Assume you meansystemctl edit
.
â Malvineous
May 18 at 7:18
Yes, sorry,systemctl edit
.
â muru
May 18 at 7:20
Have you considered adding more swap?
â Mark Stosberg
May 18 at 12:23
1
systemd won't start X. it will start a display manager: gdm, kdm, lightdm, ... . This one in turn will start X. So the change should be done in the display manager related config. For example in lightdm.conf there's this handy (commented) entry calledxserver-command =
. put a wrapper to Xorg (or to Xorg's own wrapper...) there
â A.B
May 19 at 18:06
2
2
"I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade)" ... which is why you have
systemd edit
, which will create a override file in /etc
which will be unaffected by package upgrades. That said, there won't be a service for X, since it is started and managed by your display manager, which seems to be LightDM.â muru
May 18 at 7:15
"I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade)" ... which is why you have
systemd edit
, which will create a override file in /etc
which will be unaffected by package upgrades. That said, there won't be a service for X, since it is started and managed by your display manager, which seems to be LightDM.â muru
May 18 at 7:15
Aha, didn't know about that, thanks! Assume you mean
systemctl edit
.â Malvineous
May 18 at 7:18
Aha, didn't know about that, thanks! Assume you mean
systemctl edit
.â Malvineous
May 18 at 7:18
Yes, sorry,
systemctl edit
.â muru
May 18 at 7:20
Yes, sorry,
systemctl edit
.â muru
May 18 at 7:20
Have you considered adding more swap?
â Mark Stosberg
May 18 at 12:23
Have you considered adding more swap?
â Mark Stosberg
May 18 at 12:23
1
1
systemd won't start X. it will start a display manager: gdm, kdm, lightdm, ... . This one in turn will start X. So the change should be done in the display manager related config. For example in lightdm.conf there's this handy (commented) entry called
xserver-command =
. put a wrapper to Xorg (or to Xorg's own wrapper...) thereâ A.B
May 19 at 18:06
systemd won't start X. it will start a display manager: gdm, kdm, lightdm, ... . This one in turn will start X. So the change should be done in the display manager related config. For example in lightdm.conf there's this handy (commented) entry called
xserver-command =
. put a wrapper to Xorg (or to Xorg's own wrapper...) thereâ A.B
May 19 at 18:06
 |Â
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
This is a preliminary answer, I will update it as more detail comes to hand.
systemd
does not launch X like the old runlevel system used to, but rather it launches the display manager (LightDM in my case) and it's actually the display manager that starts X.
So the question is really how one tells the display manager to alter the OOM score of the X server.
I asked a question of the LightDM developers and they seem open to the idea of including an option to set the OOM score (as having the parent process set the OOM score seems to be the better way of doing so), so it will be a matter of someone implementing that option.
Until then, the suggestion in the above comments of altering the xserver-command
config option should do the trick.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This is a preliminary answer, I will update it as more detail comes to hand.
systemd
does not launch X like the old runlevel system used to, but rather it launches the display manager (LightDM in my case) and it's actually the display manager that starts X.
So the question is really how one tells the display manager to alter the OOM score of the X server.
I asked a question of the LightDM developers and they seem open to the idea of including an option to set the OOM score (as having the parent process set the OOM score seems to be the better way of doing so), so it will be a matter of someone implementing that option.
Until then, the suggestion in the above comments of altering the xserver-command
config option should do the trick.
add a comment |Â
up vote
0
down vote
This is a preliminary answer, I will update it as more detail comes to hand.
systemd
does not launch X like the old runlevel system used to, but rather it launches the display manager (LightDM in my case) and it's actually the display manager that starts X.
So the question is really how one tells the display manager to alter the OOM score of the X server.
I asked a question of the LightDM developers and they seem open to the idea of including an option to set the OOM score (as having the parent process set the OOM score seems to be the better way of doing so), so it will be a matter of someone implementing that option.
Until then, the suggestion in the above comments of altering the xserver-command
config option should do the trick.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This is a preliminary answer, I will update it as more detail comes to hand.
systemd
does not launch X like the old runlevel system used to, but rather it launches the display manager (LightDM in my case) and it's actually the display manager that starts X.
So the question is really how one tells the display manager to alter the OOM score of the X server.
I asked a question of the LightDM developers and they seem open to the idea of including an option to set the OOM score (as having the parent process set the OOM score seems to be the better way of doing so), so it will be a matter of someone implementing that option.
Until then, the suggestion in the above comments of altering the xserver-command
config option should do the trick.
This is a preliminary answer, I will update it as more detail comes to hand.
systemd
does not launch X like the old runlevel system used to, but rather it launches the display manager (LightDM in my case) and it's actually the display manager that starts X.
So the question is really how one tells the display manager to alter the OOM score of the X server.
I asked a question of the LightDM developers and they seem open to the idea of including an option to set the OOM score (as having the parent process set the OOM score seems to be the better way of doing so), so it will be a matter of someone implementing that option.
Until then, the suggestion in the above comments of altering the xserver-command
config option should do the trick.
answered Jul 13 at 5:03
Malvineous
1,70111332
1,70111332
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444529%2fhow-to-reduce-oom-score-for-x11-with-systemd%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
"I thought I shouldn't be editing these system-owned files directly (as they'll get overwritten during an upgrade)" ... which is why you have
systemd edit
, which will create a override file in/etc
which will be unaffected by package upgrades. That said, there won't be a service for X, since it is started and managed by your display manager, which seems to be LightDM.â muru
May 18 at 7:15
Aha, didn't know about that, thanks! Assume you mean
systemctl edit
.â Malvineous
May 18 at 7:18
Yes, sorry,
systemctl edit
.â muru
May 18 at 7:20
Have you considered adding more swap?
â Mark Stosberg
May 18 at 12:23
1
systemd won't start X. it will start a display manager: gdm, kdm, lightdm, ... . This one in turn will start X. So the change should be done in the display manager related config. For example in lightdm.conf there's this handy (commented) entry called
xserver-command =
. put a wrapper to Xorg (or to Xorg's own wrapper...) thereâ A.B
May 19 at 18:06