---
title: SizeClass
description: One of the five documented size classes.
---

One of the five documented size classes.

`minimumMemoryInMiB` selects a class; it does not size a VM. Both numbers are on the
class or neither.

## Accessors

### baselineGb

#### Get Signature

```ts
get baselineGb(): number;
```

The figure a GB-second rate multiplies. Always the baseline, never the peak.

##### Returns

`number`

***

### baselineMib

#### Get Signature

```ts
get baselineMib(): number;
```

##### Returns

`number`

***

### baselineVcpu

#### Get Signature

```ts
get baselineVcpu(): number;
```

##### Returns

`number`

***

### peakGb

#### Get Signature

```ts
get peakGb(): number;
```

The peak in GB, which is what the guest reports as `MemTotal`.

##### Returns

`number`

***

### peakMib

#### Get Signature

```ts
get peakMib(): number;
```

##### Returns

`number`

***

### peakVcpu

#### Get Signature

```ts
get peakVcpu(): number;
```

##### Returns

`number`

## Methods

### describe()

```ts
describe(): string;
```

One line naming both numbers.

#### Returns

`string`

***

### all()

```ts
static all(): SizeClass[];
```

Every class, smallest first.

#### Returns

`SizeClass`\[]

***

### defaultClass()

```ts
static defaultClass(): SizeClass;
```

The platform's default, 2048 MiB. Not the smallest — a 0.5 GB baseline fixes the
guest's always-present ceiling at 2 GB, which OOM-kills a real test suite, and the
guest has no swap.

#### Returns

`SizeClass`

***

### fromBaselineMib()

```ts
static fromBaselineMib(mib: number): SizeClass;
```

The class `minimumMemoryInMiB = mib` selects, or a refusal (TRAP-10).

Off-table figures are refused rather than snapped to a neighbour: the two plausible
readings differ in both memory and rate, and neither has been measured.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `mib` | `number` |

#### Returns

`SizeClass`

***

### fromRequest()

```ts
static fromRequest(cpus?: number | null, memoryMib?: number | null): SizeClass;
```

The smallest class whose baseline covers a resource request (BIND-14).

`cpus` in vCPUs and `memoryMib` in MiB, each a request; `undefined` or zero is no
requirement on that axis, and with none on either the answer is `defaultClass()`.
Chosen by baseline, the billed and always-present figure. Throws `ERR_INVALID_ARG`
naming the largest class when no class covers the request, or for a CPU figure that is
not a finite non-negative number.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `cpus?` | `number` | `null` |
| `memoryMib?` | `number` | `null` |

#### Returns

`SizeClass`

## Provenance

This page is generated from `bindings/microvms-js/index.d.ts` by TypeDoc 0.28.20 and typedoc-plugin-markdown 4.13.1, run from `site/scripts/gen-reference.mjs` on every `pnpm run sync`, so an edit made here is overwritten by the next run.

To change the page, change the doc comment in the binding's Rust source, then regenerate the declarations with `mise run dts`. `mise run dts:check` fails when the committed file no longer matches the source.