Skip to main content

Module mem

Module mem 

Source
Expand description

SVM-optimized memory operations.

The Solana BPF VM provides syscall-level memory operations that are faster than Rust’s default libc implementations because they are JIT-compiled intrinsics in the VM. No framework exposes these at the substrate level.

On BPF, these dispatch to sol_memcpy_, sol_memmove_, sol_memcmp_, and sol_memset_. Off-chain, they fall back to standard library implementations.

Use these instead of core::ptr::copy_nonoverlapping, ptr::write_bytes, etc. for best performance on the SVM.

Functions§

bytes_eq
Compare two byte slices for equality using SVM-optimized memcmp.
copy_bytes
Copy bytes from one slice to another (no overlap).
memcmp
Compare n bytes between two memory regions.
memcpy
Copy n bytes from src to dst.
memmove
Copy n bytes from src to dst, handling overlapping regions.
memset
Fill n bytes starting at dst with byte.
zero_account_data
Zero-fill account data using SVM-optimized memset.
zero_fill
Zero-fill a mutable byte slice using the SVM-optimized memset.