vmmem

package
v0.9.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vmmem reasons about the container runtime's memory ceiling. On macOS, Docker doesn't run containers natively — colima/Docker Desktop runs a Linux VM given a FIXED slice of host RAM, and that slice is the ceiling for ALL islands combined. A too-small VM (colima defaults to 2 GB) is the substrate-level cause of island OOMs (#23): no per-island knob helps when the whole pool is 2 GB on a 24 GB host. These helpers read host RAM, recommend a VM size, and judge whether the current VM is undersized — shared by the daemon (overview → TUI banner) and `dejima doctor` (the host-side check + colima fix).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPUUndersized added in v0.9.14

func CPUUndersized(hostCPU, vmCPU int) bool

CPUUndersized reports whether the VM has meaningfully fewer cores than recommended — below ¾, mirroring Undersized so the two ceilings nag on the same terms and a deliberate, slightly-conservative VM does not.

False when either figure is unknown: an unasked question is not a finding.

func ColimaAvailable

func ColimaAvailable() bool

ColimaAvailable reports whether the colima CLI is on PATH (so the fix can be scripted). Docker Desktop has no CLI resize — its memory is a GUI slider.

func ColimaResizeCmd added in v0.9.15

func ColimaResizeCmd(cpu, memGB int) string

ColimaResizeCmd is the operator-facing one-liner for an EXISTING VM. colima cannot resize a running VM, hence the stop.

func ColimaStartArgs added in v0.9.15

func ColimaStartArgs(cpu, memGB int) []string

ColimaStartArgs is the argv for a `colima start` that sizes both dimensions. Shared so the command we PRINT and the command we RUN cannot drift apart.

func ColimaStartCmd added in v0.9.15

func ColimaStartCmd(cpu, memGB int) string

ColimaStartCmd is the same sizing for a VM that does not exist yet, where there is nothing to stop first.

func HostMemoryBytes

func HostMemoryBytes() uint64

HostMemoryBytes returns the host's physical RAM (cached — it doesn't change over a process's life). macOS: `sysctl hw.memsize`. Linux: MemTotal from /proc/meminfo. 0 when it can't be determined (callers treat 0 as "unknown", never as a problem).

func RecommendedBytes

func RecommendedBytes(host uint64) uint64

RecommendedBytes is the VM size to suggest for a host: three-quarters of host RAM, but always leaving the host at least 4 GiB so macOS itself isn't starved — min(¾·host, host−4 GiB) — rounded down to a whole GiB, floored at 2 GiB. 0 when host is unknown.

func RecommendedCPU added in v0.9.14

func RecommendedCPU(hostCPU int) int

RecommendedCPU is the VM CPU count to suggest for a host: all but two cores, leaving the host itself something to run on, floored at 2. 0 when unknown.

The same arithmetic the colima repair in `dejima doctor` already used when it resized for MEMORY — lifted here so it is a shared rule with a name rather than a number that happened to live inside one fix.

func RecommendedGB

func RecommendedGB(host uint64) int

RecommendedGB is RecommendedBytes in whole GiB (for the colima --memory flag).

func ResizeTo added in v0.9.15

func ResizeTo(hostCPU int, hostBytes uint64, vmCPU int, vmBytes uint64) (cpu, memGB int)

ResizeTo computes the sizing a `colima start` should apply to BOTH dimensions: the RECOMMENDATION for a dimension that is undersized, and the VM's CURRENT value for one that is not.

Both flags, always. Omitting one is the whole bug: `colima start --memory N` applies the memory and leaves CPU at colima's 2-core default, so an operator who fixes an OOM the way we told them to ends up memory-correct and CPU-starved with every check green. That is not a hypothetical — it read as "the Mac mini is too small" for a day on a 10-core host running nine islands.

And the value for the HEALTHY dimension is the current one, not the recommendation, because a passing check is not an invitation to resize. The ceilings nag below ¾ of recommended, so a deliberately conservative VM passes on purpose; an operator who chose 8 cores on a 12-core host gets to keep 8. The two doctor checks used to disagree about this — the CPU repair carried the VM's real memory through while the memory repair quietly reset CPU to the recommendation — and disagreeing was the defect, whichever answer won.

A current value of zero means "no VM yet, or unreadable", and yields the recommendation: at install time there is no operator choice to preserve.

func Undersized

func Undersized(host, vm uint64) bool

Undersized reports whether the VM is meaningfully smaller than recommended — the trigger for the doctor warning + TUI banner. Only fires when there's real headroom being wasted (VM below ¾ of the recommendation), so a VM that's merely a bit under ideal doesn't nag. False when either figure is unknown.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL