realloc & Growing Accounts
Programs can grow (or shrink) account data via the realloc syscall/CPI, paying additional rent from a payer. Required when schemas grow or dynamic collections expand.
Search across all documentation pages
Programs can grow (or shrink) account data via the realloc syscall/CPI, paying additional rent from a payer. Required when schemas grow or dynamic collections expand.
account.realloc(new_len, false)?;
account.transfer_required_rent(payer)?; // conceptually - use realloc CPI patternWhen to reach for this:
// Native: use solana_program::program::realloc or system CPI patterns per SDK
// After realloc, zero new bytes and initialize new fields
let new_len = old_len + 8;
// realloc account to new_len with payer funding rent deltaWhat this demonstrates:
realloc constraint in 0.32.1.
// Document max_len to cap griefing.| Alternative | Use When | Don't Use When |
|---|---|---|
| New account migration | Safer | User friction |
| Fixed max size upfront | Wastes rent early | Simple |
| Off-chain storage | Cheap | Trust model |
Payer signer you specify.
10 MB account cap.
To chosen recipient.
Attribute on account.
Tx serialization per account.
Required security practice.
Common upgrade path.
Supported.
Profile realloc ix.
Payer yes.
Set absolute new length.
Plan size headroom early.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026