Skip to content

Add Store#close#624

Merged
saulecabrera merged 1 commit into
bytecodealliance:mainfrom
omohokcoj:close
Jul 6, 2026
Merged

Add Store#close#624
saulecabrera merged 1 commit into
bytecodealliance:mainfrom
omohokcoj:close

Conversation

@omohokcoj

Copy link
Copy Markdown
Contributor

This PR adds Store#close, making it possible to free up Wasm memory deterministically.

store = Wasmtime::Store.new(engine)
instance = Wasmtime::Instance.new(store, mod)
instance.invoke('process', input)

store.closed?  # => false
store.close    # => true  (frees Wasm memory, false if already closed)
store.closed?  # => true

# The store and anything created from it can no longer be used:
instance.invoke('process', input) # => raises Wasmtime::Error: Wasmtime::Store is closed

@saulecabrera saulecabrera left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@saulecabrera saulecabrera merged commit 5041359 into bytecodealliance:main Jul 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants