Table of Contents

Class MemoryAgentPolicy

Namespace
McServerLauncher.Services
Assembly
McServerLauncher.dll

Decides, from how much memory the machine has free, whether the agent should hold a server's heap tighter. Pure: the app decides, the agent only carries it out.

public static class MemoryAgentPolicy
Inheritance
MemoryAgentPolicy
Inherited Members

Remarks

With the machine's free memory under 15 %, servers with nobody on tighten first: giving back what an empty server holds costs nobody anything. A server with players waits until it is under 10 %, when the machine is about to start swapping and a slightly busier collector is the lesser evil. Everything goes back to the relaxed margins only above 25 %: the gap is what keeps it from flapping when free memory hovers around one threshold.

The margins are the ones the lab found to give back the most without costing tick time; they are applied at run time because they cost a little collection time, which is worth paying only while the machine needs the memory.

Fields

Relax

Above this share every server goes back to the relaxed margins.

public const double Relax = 0.25

Field Value

double

RelaxedValues

The margins the app gives a server at start (they match MemoryProfile).

public static readonly (int MinFree, int MaxFree, int PeriodicMs) RelaxedValues

Field Value

(int MinFree, int MaxFree, int PeriodicMs)

TightValues

The tight margins.

public static readonly (int MinFree, int MaxFree, int PeriodicMs) TightValues

Field Value

(int MinFree, int MaxFree, int PeriodicMs)

TightenEmpty

Below this share of free memory a server with nobody on is tightened.

public const double TightenEmpty = 0.15

Field Value

double

TightenWithPlayers

Below this share a server with players is tightened too.

public const double TightenWithPlayers = 0.1

Field Value

double

Methods

ControlText(HeapMargins)

The text of the control file for a set of margins, as the agent reads it.

public static string ControlText(HeapMargins margins)

Parameters

margins HeapMargins

Returns

string

Decide(HeapMargins, double, int)

The margins to hold now.

public static HeapMargins Decide(HeapMargins current, double freeShare, int players)

Parameters

current HeapMargins

What the server has now.

freeShare double

The machine's free memory as a share of its total, 0 to 1; negative when unknown.

players int

Players on the server.

Returns

HeapMargins