Also do you mind writing this as a two statements? The Scala style is to avoid multi-line expressions when possible:

```
val reservedMemorySize = memoryStringToMb(conf.get("spark.system.reservedMemorySize", "300m"))
Runtime.getRuntime.maxMemory - (1024 * 1024 * reservedMemorySize)
```