Documentation
¶
Overview ¶
Package dockermem measures the memory a stack has to fit into, and what is already in it.
Declared limits are useless for this: one my-app stack declares more than 13 GB of mem_limit across its services yet runs in about 2 GB, because mem_limit is a ceiling and not a reservation. Only measurement tells you whether one more stack fits.
Where that memory lives decides what counts as used. Docker Desktop holds a budget of its own, so the containers are all of it; a native Linux docker shares the machine with the user's session, so the desktop and the browser count too. See Usage.Shared.
Index ¶
Constants ¶
const WarnRatio = 0.85
WarnRatio is the share of the available memory above which starting one more stack is worth a warning.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Usage ¶
type Usage struct {
Total int64 // bytes the containers have to fit into
Used int64 // bytes already used, by the containers alone unless Shared
// StackUsed excludes one-off `compose run` containers: a migration
// container peaking at 6 GB is not what a stack costs, and counting it
// would triple the estimate.
StackUsed int64
Projects int // distinct compose projects, one-offs excluded
// native Linux docker. There the containers compete with the user's own
// session for one pool of RAM, so Used is what the whole machine uses and
// not the sum of the containers: a desktop holding 6 GB is pressure the
// containers cannot see, and ignoring it made the warning fire long after
// the machine had started to thrash. Docker Desktop, on macOS or through
// WSL2, gives the containers a budget of their own, where that sum IS the
// pressure.
Shared bool
}
func (Usage) PerProject ¶
PerProject is the average cost of a running stack, the best available estimate of what one more would cost.