Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: never remove ipc callback & mem never be released #4274

Merged
merged 2 commits into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/fix-memory-leak-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": patch
"api": patch
---

Fixes a memory leak in the command system.
2 changes: 1 addition & 1 deletion core/tauri/scripts/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/tauri/scripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
return new Promise(function (resolve, reject) {
var callback = window.__TAURI__.transformCallback(function (r) {
resolve(r)
delete window[error]
delete window[`_${error}`]
}, true)
var error = window.__TAURI__.transformCallback(function (e) {
reject(e)
delete window[callback]
delete window[`_${callback}`]
}, true)

if (typeof cmd === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions tooling/api/src/tauri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ async function invoke<T>(cmd: string, args: InvokeArgs = {}): Promise<T> {
return new Promise((resolve, reject) => {
const callback = transformCallback((e: T) => {
resolve(e)
Reflect.deleteProperty(window, error)
Reflect.deleteProperty(window, `_${error}`)
}, true)
const error = transformCallback((e) => {
reject(e)
Reflect.deleteProperty(window, callback)
Reflect.deleteProperty(window, `_${callback}`)
}, true)

window.__TAURI_IPC__({
Expand Down