Table of Contents

Class MemoryProfile

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

Decides how much memory a server may use and the JVM flags that make it use no more than it needs.

public static class MemoryProfile
Inheritance
MemoryProfile
Inherited Members

Remarks

Measured on 2026-10-21/22 with bots on Minecraft 26.2: a fixed -Xms/-Xmx commits whatever the heap ever reached and keeps it, so an empty server sat on 3.5-4.7 GB. With a small initial heap, G1's periodic collection and low free-heap margins, the same servers came back to 0.9-1.1 GB a few minutes after the last player left (−69 % to −81 %), with the same tick time.

The ceiling is a limit, not a reservation: with these flags the JVM only commits what it uses. That is why it is generous. Too low costs much more than too high — at 768 MB the test server ran out of memory, at 1 GB its tick suffered — while a high ceiling costs nothing until it is needed.

Every flag is given only from the Java release where it is final: a JVM refuses to start over an option it does not know. Pure, so all of it is testable without a JVM.

Fields

InitialHeapMb

The initial heap in Automatic mode, in MB: what an empty 26.x server holds.

public const int InitialHeapMb = 128

Field Value

int

ThirtyTwoBitCeilingMb

The largest heap a 32-bit JVM can reliably reserve, in MB.

public const long ThirtyTwoBitCeilingMb = 1024

Field Value

long

Methods

AutomaticFlags(JavaRuntime, long, string?)

The flags that let the heap follow what the server uses, for this Java.

public static IReadOnlyList<string> AutomaticFlags(JavaService.JavaRuntime java, long ceilingMb, string? extraArgs)

Parameters

java JavaService.JavaRuntime
ceilingMb long
extraArgs string

Returns

IReadOnlyList<string>

Remarks

  • Java 12 and later: G1's periodic collection (JEP 346) and low free-heap margins, which return memory when the server goes quiet. Before 12 there is no periodic collection, and the margins alone only act on a full collection, so they are not worth an option.
  • Java 25 and later: compact object headers (JEP 519), final from 25 and experimental in 24, where they would need an unlock flag.
  • OpenJ9 rejects HotSpot's -XX: options and gets only the heap size.

BudgetMb(long, bool)

The memory all running servers may share as ceilings, in MB. 0 when the machine's is unknown.

public static long BudgetMb(long totalRamMb, bool dedicated)

Parameters

totalRamMb long
dedicated bool

Returns

long

Remarks

Half the machine by default, because the case that matters is a PC somebody also plays on: the game, the browser and the system need the other half. A machine kept only for servers gives them everything but 2 GB.

CountMods(ServerConfig)

Jars in the server's mods folder, not counting disabled ones. 0 for other types.

public static int CountMods(ServerConfig config)

Parameters

config ServerConfig

Returns

int

Effective(ServerConfig)

The mode that applies: Manual when the extra JVM arguments already size the memory, otherwise the one saved, and Automatic for a server that never chose.

public static MemoryMode Effective(ServerConfig config)

Parameters

config ServerConfig

Returns

MemoryMode

EstimateCeilingMb(int)

The ceiling a server starts with before anything has been learned about it, in MB.

public static long EstimateCeilingMb(int modCount)

Parameters

modCount int

Returns

long

Remarks

Four players exploring new terrain peaked at 1.1-1.6 GB of heap on Fabric and Paper; the 33-mod test server at 1.7 GB with a lighter load. These leave more than twice that.

FloorMb(int)

The lowest ceiling the app gives a server, in MB, whatever the budget says.

public static long FloorMb(int modCount)

Parameters

modCount int

Returns

long

HasMods(ServerType)

True for the server types whose mods folder is read for the estimate.

public static bool HasMods(ServerType type)

Parameters

type ServerType

Returns

bool

ManualFlags(ServerConfig)

Manual mode's flags: the owner's two numbers, exactly as the app always passed them.

public static IReadOnlyList<string> ManualFlags(ServerConfig config)

Parameters

config ServerConfig

Returns

IReadOnlyList<string>

Plan(MemoryInputs)

Decides the mode, the ceiling and the memory flags a server starts with.

public static MemoryPlan Plan(MemoryInputs inputs)

Parameters

inputs MemoryInputs

Returns

MemoryPlan

ShowsMigrationNotice(ServerConfig)

True for a server moved to Automatic by the update without its owner having chosen: it shows the one-line notice that offers its old numbers back.

public static bool ShowsMigrationNotice(ServerConfig config)

Parameters

config ServerConfig

Returns

bool

WithoutLastOptionalFlag(MemoryPlan)

The same plan with fewer flags, for a Java that refused the full set: compact headers go first, then the G1 options. The heap size always stays.

public static MemoryPlan? WithoutLastOptionalFlag(MemoryPlan plan)

Parameters

plan MemoryPlan

Returns

MemoryPlan

Null when there is nothing left to drop.