mirror of
https://github.com/github/codeql-action.git
synced 2026-04-02 01:32:17 +00:00
Improve docs
This commit is contained in:
17
lib/util.js
generated
17
lib/util.js
generated
@@ -149,14 +149,19 @@ function getMemoryFlagValueForPlatform(userInput, totalMemoryBytes, platform) {
|
||||
}
|
||||
exports.getMemoryFlagValueForPlatform = getMemoryFlagValueForPlatform;
|
||||
/**
|
||||
* Get the total amount of memory available to the Action.
|
||||
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
||||
* by cgroups on Linux.
|
||||
*/
|
||||
function getTotalMemoryAvailable() {
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"));
|
||||
}
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
if (os.platform() === "linux") {
|
||||
// Respect constraints imposed by Linux cgroups v1
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"));
|
||||
}
|
||||
// Respect constraints imposed by Linux cgroups v2
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
}
|
||||
}
|
||||
return os.totalmem();
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
21
src/util.ts
21
src/util.ts
@@ -212,16 +212,21 @@ export function getMemoryFlagValueForPlatform(
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total amount of memory available to the Action.
|
||||
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
||||
* by cgroups on Linux.
|
||||
*/
|
||||
function getTotalMemoryAvailable(): number {
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(
|
||||
fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"),
|
||||
);
|
||||
}
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
if (os.platform() === "linux") {
|
||||
// Respect constraints imposed by Linux cgroups v1
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory/memory.limit_in_bytes")) {
|
||||
return Number(
|
||||
fs.readFileSync("/sys/fs/cgroup/memory/memory.limit_in_bytes", "utf8"),
|
||||
);
|
||||
}
|
||||
// Respect constraints imposed by Linux cgroups v2
|
||||
if (fs.existsSync("/sys/fs/cgroup/memory.max")) {
|
||||
return Number(fs.readFileSync("/sys/fs/cgroup/memory.max", "utf8"));
|
||||
}
|
||||
}
|
||||
return os.totalmem();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user