Skip to content

Commit

Permalink
feat: wasmtime 17.0.0, arrow 50.0.0, fix not releasing memory in case…
Browse files Browse the repository at this point in the history
… of an error calling function
  • Loading branch information
jornfranke committed Feb 6, 2024
1 parent 9ce1838 commit 37bfeee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions wasm-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
anyhow = {version = "1.0.76"}
arrow = { version = "49.0.0", default-features = false, features = ["ipc","prettyprint"] }
arrow = { version = "50.0.0", default-features = false, features = ["ipc","prettyprint"] }
time = {version = "0.3.31", features = ["macros"]}
wasmtime = { version = "16.0.0"}
wasmtime-wasi = { version = "16.0.0"}
wasmtime = { version = "17.0.0"}
wasmtime-wasi = { version = "17.0.0"}
25 changes: 13 additions & 12 deletions wasm-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,17 +419,6 @@ fn wrapper_wasm_process_data_arrow(engine: &Engine, module: &Module) -> anyhow::
result_ptr.try_into().unwrap(),
&mut result_arrow_ipc_buffer,
)?;
// deallocate shared WASM Module memory
let dealloc_meta_data_code: i32 =
wrapper_wasm_deallocate(instance, &mut store, offset_meta_data as *const u8).unwrap();
if dealloc_meta_data_code != 0 {
println!("Error: Could not deallocate shared WASM module memory for meta data");
}
let dealloc_data_code: i32 =
wrapper_wasm_deallocate(instance, &mut store, offset_data as *const u8).unwrap();
if dealloc_data_code != 0 {
println!("Error: Could not deallocate shared WASM module memory for data");
}
let dealloc_return_meta_code: i32 =
wrapper_wasm_deallocate(instance, &mut store, result_offset as *const u8).unwrap();
if dealloc_return_meta_code != 0 {
Expand All @@ -447,8 +436,20 @@ fn wrapper_wasm_process_data_arrow(engine: &Engine, module: &Module) -> anyhow::
for item in stream_reader {
print_batches(&[item.unwrap()]).unwrap();
}
Ok("".to_string())
}
// deallocate shared WASM Module memory
let dealloc_meta_data_code: i32 =
wrapper_wasm_deallocate(instance, &mut store, offset_meta_data as *const u8).unwrap();
if dealloc_meta_data_code != 0 {
println!("Error: Could not deallocate shared WASM module memory for meta data");
}
let dealloc_data_code: i32 =
wrapper_wasm_deallocate(instance, &mut store, offset_data as *const u8).unwrap();
if dealloc_data_code != 0 {
println!("Error: Could not deallocate shared WASM module memory for data");
}

Ok("".to_string())
}

/// Wrapper around the allocate function of the WASM module to allocate shared WASM memory. Allocate some memory for the application to write data for the module
Expand Down
2 changes: 1 addition & 1 deletion wasm-module2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ edition = "2021"
crate-type = ['cdylib']

[dependencies]
arrow = { version = "49.0.0", default-features = false, features = ["ipc"] }
arrow = { version = "50.0.0", default-features = false, features = ["ipc"] }
time = {version = "0.3.31", features = ["macros"]}

0 comments on commit 37bfeee

Please sign in to comment.