Local Orders Lab now uses an existing compiled SQL engine. When an import becomes large, saying that the app passes an array to Wasm is too vague to explain its cost or lifetime. Which array? Who owns it? Does the callee retain a reference? Can the memory move or grow? Those questions determine whether a change saves work or introduces a subtle failure.
Start by separating three things. The .wasm download contains program bytes. The SQLite export contains database-file bytes. The engine's linear memory contains runtime data such as allocations and working state. All three can appear in JavaScript through byte-oriented APIs, but they are not interchangeable. A database export is not the whole Wasm heap, and the engine binary is not a database snapshot.
| Bytes | Who interprets them? | Reason to keep them |
|---|---|---|
| SQLite .wasm artifact | The WebAssembly compiler and runtime | Reuse a versioned program download |
| Exported .sqlite database | SQLite's database-file reader | Save or restore application data |
| WebAssembly.Memory.buffer | Compiled instructions and authorized JS views | Hold this instance's runtime storage |
| An order batch ArrayBuffer | Our documented application protocol | Send validated records to an owner |