fix memory limiting java & kotlin
All checks were successful
Build and Push Docker Images / build (src/LiquidCode.Tester.Gateway/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-gateway-roman, gateway) (push) Successful in 43s
Build and Push Docker Images / build (src/LiquidCode.Tester.Worker/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-worker-roman, worker) (push) Successful in 1m13s

This commit is contained in:
prixod
2025-12-01 22:52:18 +04:00
parent 7a1f22eb8e
commit f009c95645
2 changed files with 24 additions and 6 deletions

View File

@@ -64,16 +64,25 @@ public class KotlinExecutionServiceIsolate : IExecutionService
}
// Run in Isolate (Kotlin runs via Java)
var kotlinMemoryMb = Math.Max(memoryLimitMb, 128); // Minimum 128MB for JVM
// We set JVM heap limit to the requested memory, but give Isolate more for JVM internals
var jvmHeapMb = memoryLimitMb;
var jvmTotalMemoryMb = memoryLimitMb + 64; // Add 64MB for JVM overhead
var arguments = new List<string>
{
$"-Xmx{jvmHeapMb}m", // Max heap size = requested memory limit
$"-Xms{Math.Min(jvmHeapMb, 32)}m", // Initial heap size
"-jar", $"/box/{jarName}"
};
var isolateResult = await _isolateService.RunAsync(new IsolateRunOptions
{
BoxId = boxId,
Executable = "/usr/bin/java",
Arguments = new[] { "-jar", $"/box/{jarName}" },
Arguments = arguments.ToArray(),
TimeLimitSeconds = timeLimitMs / 1000.0,
WallTimeLimitSeconds = (timeLimitMs / 1000.0) * 2,
MemoryLimitKb = kotlinMemoryMb * 1024,
MemoryLimitKb = jvmTotalMemoryMb * 1024,
StackLimitKb = 256 * 1024,
ProcessLimit = 64, // JVM creates multiple threads
EnableNetwork = false,