I was working on some code today, and I noticed that I couldn't reallocate an account by a difference of morethan 10KB. I reckon that I could do multiple reallocs to achieve any desired size, but given that per realloc, there is already a set limit, I am wondering whether it is a safe habit to do multiple reallocs, and why there is even the 10KB limit to start with.
thanks
/// Maximum number of bytes a program may add to an account during a
single realloc
pub const MAX_PERMITTED_DATA_INCREASE: usize = 1_024 * 10;
// Return early if the length increase from the original serialized data
// length is too large and would result in an out of bounds allocation.
let original_data_len = unsafe { self.original_data_len() };
if new_len.saturating_sub(original_data_len) > MAX_PERMITTED_DATA_INCREASE {
return Err(ProgramError::InvalidRealloc);
}
the code excerpt is a mixture of slivers of the Solana program.