-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
earlyoom used to calculate the memory and swap limits to absolute kilobyte values on startup, even if percentages were given by the user. This model breaks down once swap space is added dynamically on runtime. Switch to always using limits as a percentage of total memory and swap. If the user passes kilobytes values (-S and -M), these are converted to a percentage at startup. Fixes #62 Low memory output now looks like this: Low memory! mem avail: 228 of 7836 MiB (2) % <= min 10 %, swap free: 8 of 99 MiB (8 %) <= min 10 % Killing process: tail, pid: 14259, badness: 629, VmRSS: 1246 MiB Fixes #66 Fixes #60
- Loading branch information
Showing
5 changed files
with
68 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
/* SPDX-License-Identifier: MIT */ | ||
|
||
struct meminfo { | ||
long MemTotal; | ||
long MemAvailable; | ||
long SwapTotal; | ||
long SwapFree; | ||
/* -1 means no data available */ | ||
// Values from /proc/meminfo, in KiB or converted to MiB. | ||
long MemTotalKiB; | ||
int MemTotalMiB; | ||
int MemAvailableMiB; // -1 means no data available | ||
int SwapTotalMiB; | ||
long SwapTotalKiB; | ||
int SwapFreeMiB; | ||
// Calculated percentages | ||
int MemAvailablePercent; // percent of total memory that is available | ||
int SwapFreePercent; // percent of total swap that is free | ||
}; | ||
|
||
struct meminfo parse_meminfo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters