@@ -527,6 +527,8 @@ public struct DefaultVolumePopulator: VolumePopulator {
527527/// )
528528/// ```
529529public actor Orchestrator {
530+ static let defaultServiceMemoryInBytes : UInt64 = 6144 . mib ( )
531+
530532 public enum PullPolicy : String , Sendable {
531533 case always
532534 case missing
@@ -1276,22 +1278,7 @@ public actor Orchestrator {
12761278 if let cpus = service. cpus {
12771279 config. resources. cpus = Int ( cpus) ?? 4
12781280 }
1279- if let memStr = service. memory, !memStr. isEmpty {
1280- do {
1281- if memStr. lowercased ( ) == " max " {
1282- // Treat "max" as no override: keep the runtime/default value (set below if needed).
1283- // Intentionally do nothing here.
1284- } else {
1285- let res = try Parser . resources ( cpus: nil , memory: memStr)
1286- if let bytes = res. memoryInBytes as UInt64 ? { config. resources. memoryInBytes = bytes }
1287- }
1288- } catch {
1289- log. warning ( " Invalid memory value ' \\ (memStr)'; using default. Error: \\ (error) " )
1290- }
1291- } else {
1292- // Safer default for dev servers (was 1 GiB)
1293- config. resources. memoryInBytes = 2048 . mib ( )
1294- }
1281+ config. resources. memoryInBytes = resolvedMemoryLimit ( for: service)
12951282
12961283 labels [ " com.apple.container.compose.config-hash " ] = computeConfigHash (
12971284 project: project,
@@ -1307,6 +1294,27 @@ public actor Orchestrator {
13071294 return config
13081295 }
13091296
1297+ func resolvedMemoryLimit( for service: Service) - > UInt64 {
1298+ guard let memStr = service. memory, !memStr. isEmpty else {
1299+ return Self . defaultServiceMemoryInBytes
1300+ }
1301+
1302+ do {
1303+ if memStr. lowercased ( ) == " max " {
1304+ return Self . defaultServiceMemoryInBytes
1305+ }
1306+
1307+ let res = try Parser . resources ( cpus: nil , memory: memStr)
1308+ if let bytes = res. memoryInBytes as UInt64 ? {
1309+ return bytes
1310+ }
1311+ } catch {
1312+ log. warning ( " Invalid memory value ' \\ (memStr)'; using default. Error: \\ (error) " )
1313+ }
1314+
1315+ return Self . defaultServiceMemoryInBytes
1316+ }
1317+
13101318 private func publishSpec( from port: PortMapping) - > String {
13111319 let protoSuffix = port. portProtocol == " tcp " ? " " : " / \( port. portProtocol) "
13121320 if let hostIP = port. hostIP, !hostIP. isEmpty {
0 commit comments