FFI and Interoperability — Middle¶
Use C-compatible layouts only where promised. Pin or copy objects when a moving collector could relocate them. Translate error codes at the boundary, and specify whether callbacks may arrive on foreign threads. Batch work to amortize crossing and marshalling costs.
Test yourself¶
- When must memory be pinned?
- Why are coarse FFI calls preferable?
- How do callbacks affect thread safety?
Continue to senior.md.