]> git.ipfire.org Git - pakfire.git/commitdiff
build: Make memory limit configurable
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Aug 2022 11:09:36 +0000 (11:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 19 Aug 2022 11:09:36 +0000 (11:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c
tests/pakfire.conf

index c79645fdd3e76d747b0c21b243a4601d7098684b..fead677bfcd33d28cf3589045ba1adf6d0969972 100644 (file)
@@ -843,6 +843,14 @@ static int pakfire_build_setup_cgroup(struct pakfire_build* build) {
                        goto ERROR;
        }
 
+       // Limit memory
+       size_t memory_limit = pakfire_config_get_bytes(config, "build", "memory_limit", 0);
+       if (memory_limit) {
+               r = pakfire_cgroup_set_memory_limit(build->cgroup, memory_limit);
+               if (r)
+                       goto ERROR;
+       }
+
        // Set PID limit
        size_t pid_limit = pakfire_config_get_int(config, "build",
                "pid_limit", PAKFIRE_BUILD_PID_LIMIT);
index 286e70d8b3b6e7a3f090c2dd428a33927efae85a..b97f35fcb57216d8ebe2fe52c28ba97994126026 100644 (file)
@@ -13,5 +13,8 @@ slogan                = Always code as if the guy who ends up maintaining your code will be a
 # Guaranteed memory for the build environment
 memory_guaranteed = 256M
 
+# Memory limit for the build environment
+memory_limit = 1G
+
 # PID limit for the build environment
 pid_limit = 512