solana
solana copied to clipboard
Programs are unaware of non-default heap sizes
Problem
When transactions request extra heap size via the ComputeBudgetInstruction::RequestHeapFrame
, programs still run out of memory at the 32Kb default heap size.
The culprit is the default allocator that is unaware of the extra heap and always defaults to the default heap size as linked bellow. When changing the default value to match the higher heap frame size, everything works, but still stuck with a static value that is not useful for programs with multiple instructions which only some require custom heap sizes. https://github.com/solana-labs/solana/blob/cd7f03bc88c0f32aa2583029572c73a26955242b/sdk/program/src/entrypoint.rs#L168C13-L168C50
Proposed Solution
There should be a way for the program allocator to become aware of the current heap size allocated by the VM, but I'm not comfortable with the VM to propose actual solutions.