How to reduce OOM score for X11 with systemd

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question

















  • 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















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.







share|improve this question

















  • 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













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.







share|improve this question













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.









share|improve this question












share|improve this question




share|improve this question








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 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













  • 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








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











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.






share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    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






























    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer













        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.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jul 13 at 5:03









        Malvineous

        1,70111332




        1,70111332






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            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













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay