I want to create a PDA account to store data about participants' wallet addresses and their deposit amounts. I have used a PDA account to store this information. It works fine when I set the array size to 100, but I encounter an error when I try to set a larger array size. I have sufficient funds to cover the rent, but I am still facing this error when creating the PDA.

impl AllParticipants {
    pub const MAX: usize = 500;
    // Discriminator + Vec + (PubKey + u64) * Donators Amount
    pub const SIZE: usize = 8 + 4 + (32 + 8) * AllParticipants::MAX;

    pub fn binary_search<T: Ord>(
        sorted_vec: &[T],
        target: T,
    ) -> std::result::Result<usize, anchor_lang::error::Error> {
        let mut low = 0;
        let mut high = sorted_vec.len();

        while low < high {
            let mid = (low + high) / 2;
            match sorted_vec[mid].cmp(&target) {
                std::cmp::Ordering::Less => low = mid + 1,
                std::cmp::Ordering::Equal => return Ok(mid),
                std::cmp::Ordering::Greater => high = mid,
        return Err(ProgramError::Custom(99).into());

**Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Failed to reallocate account data**

1 Answer 1


You can only reallocate up to 1024 * 10 bytes per instruction: https://github.com/solana-labs/solana/blob/70107e2196c12ef46d73788c55502ffd3fe2080e/sdk/program/src/entrypoint.rs#L263

This account size grows to more than 20KB, so you're likely running into this limit.

If you need to make the account that big, you'll need to do it in 10KB increments over multiple transactions. You might even be able to do it in different instructions in the same transaction, but I can't remember if the limit is at the top-level instruction or transaction.

  • I have taken almost 100 addresses as an array, so if I want to take more than 100, is there anything else we can use for this?
    – Maidi
    Oct 26, 2023 at 5:28
  • You can also avoid using a PDA and just allocate a very large account from the start
    – Jon C
    Oct 27, 2023 at 10:21
  • thanks for reply - How can I do this? can you please share the method?
    – Maidi
    Oct 27, 2023 at 11:14
  • Certainly, you can call system_instruction::create_account and pass up to 10 million as the size, for 10MB: github.com/solana-labs/solana/blob/…
    – Jon C
    Oct 28, 2023 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.