Can I tell Linux not to swap out a particular processes' memory?

后端 未结 7 1988
孤城傲影
孤城傲影 2020-12-02 13:29

Is there a way to tell Linux that it shouldn\'t swap out a particular processes\' memory to disk?

Its a Java app, so ideally I\'m hoping for a way to do this from th

7条回答
  •  清歌不尽
    2020-12-02 13:51

    Except in extremely unusual circumstances, asking this question means that You're Doing It Wrong(tm).

    Seriously, if Linux wants to swap and you're trying to keep your process in memory then you're putting an unreasonable demand on the OS. If your app is that important then 1) buy more memory, 2) remove other apps/daemons from the machine, or dedicate a machine to your app, and/or 3) invest in a really fast disk subsystem. These steps are reasonable for an important app. If you can't justify them, then you probably can't justify wiring memory and starving other processes either.

提交回复
热议问题