I've an account like this:
#[account]
#[derive(Default, InitSpace)]
pub struct Blacklist {
pub access_controller: Pubkey,
#[max_len(318)] // that touches realloc limit 10KB
pub addresses: Vec<Pubkey>,
}
I use this to blacklist addresses and when it consumes all the initial allocation 10212
bytes (which is little less than the realloc limit 10KB
), then I realloc additional 10KB
; now I can add roughly 320 more elements to the vector. But when the vector's len is 512
(which is its capacity as well), it needs to expand which causes:
Error: memory allocation failed, out of memory
I probably understand why it gives this error because the program cannot allocate more than 32KB
of memory, which is the max heap size of allocator an instruction can use, as per the Solana docs.
Programs have access to a runtime heap either directly in C or via the Rust alloc APIs. To facilitate fast allocations, a simple 32KB bump heap is utilized. The heap does not support free or realloc so use it wisely.
Now my question is, if the heap max size is 32KB
only and it cannot grow bigger than that, then how can an account ever grow to 10MB
which is the limit of the account size?