There are several ways of storing and accessing blocks of memory in an OCaml program, including
bytes
andstring
values for mutable and immutable strings that reside in the OCaml heapbigarray
values for reference-counted blocks that reside in the OCaml heaps- Ctypes
ptr
values that can be used to address arbitrary addresses using typed descriptions of the memory layout. - Ctypes
carray
values that provide bounds-checked access toptr
-addressed memory.
The Memcpy
module provides functions for safely and efficiently copying blocks of memory between these different representations.