Skip to main content
When initializing accounts, you must specify the space (size in bytes) required.

Basic formula

Type sizes

InitSpace derive

Use InitSpace for automatic calculation:

String and Vec lengths

Specify max lengths with attributes:

Manual calculation

Best practices

Always use InitSpace derive to avoid calculation errors.
Allocate enough space for dynamic types (String, Vec) based on expected max size.