I am developing a program on Solana and I have to store around 1 MB of state into the account (Given accounts can store up to 10 MB of data) however, whenever I try to serialize that data to add it to the account, right at the serialization operation it fails and spits out the Error: memory allocation failed, out of memory which I believe is happening because of the 32kb limit for bpf programs. I tried several serializers Borsh, Bincode, and serde_json nothing seems to work. Any help would be appreciated.
The exact error messages are included below:
EDIT: I am not using native and have written my program using the solana program library.
Program log: Error: memory allocation failed, out of memory Program 9Sn8j5ZRtGqUM14WQG9KLf5QBgrSCnJL3pWEKrVrLy54 consumed 365701 of 1400000 compute units Program failed to complete: BPF program panicked Program 9Sn8j5ZRtGqUM14WQG9KLf5QBgrSCnJL3pWEKrVrLy54 failed: Program failed to complete