You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
There appears to be a memory leak when using webview.evaluate_script().
During testing, continuous calls to this method result in significant memory growth.
The webview process grows to approximately 870MB while the backend reaches 130MB after 2 million iterations.
Steps To Reproduce
Create a new Rust project with the following dependencies:
[dependencies]
wry = { version = "0.48.1" }
tao = { version = "0.31.1" }
Use the following code in main.rs:
use tao::{
event::{Event,WindowEvent},
event_loop::{ControlFlow,EventLoop},
window::WindowBuilder,};use wry::WebViewBuilder;fnmain() -> wry::Result<()>{let event_loop = EventLoop::new();let window = WindowBuilder::new().build(&event_loop).unwrap();let builder = WebViewBuilder::new().with_url("https://tauri.app");let webview = builder.build(&window)?;let event_loop_proxy = event_loop.create_proxy();
std::thread::spawn(move || {for i in0..2000000{// send event to the event loopifletErr(e) = event_loop_proxy.send_event(()){eprintln!("{e}");}// sleep for a second every 10000 iterationsif i % 10000 == 0{
std::thread::sleep(std::time::Duration::from_secs(1));}}});letmut i = 0;
event_loop.run(move |event, _, control_flow| {*control_flow = ControlFlow::Wait;match event {Event::WindowEvent{event:WindowEvent::CloseRequested,
..
} => {*control_flow = ControlFlow::Exit;}Event::UserEvent(()) => {
i += 1;let _ = webview.evaluate_script(&format!(r"document.querySelector('.tagline').textContent = '{i}'",));}
_ => (),}});}
Build and run the project:
cargo build --release
Let it run until the counter approaches 2,000,000 and observe the memory usage in Task Manager.
Expected behavior
The memory usage should remain stable or have minimal growth over time when repeatedly calling evaluate_script. Instead, it continuously grows, indicating a memory leak.
Screenshots
Webview process memory usage 870MB
Backend memory usage 130MB
Platform and Versions (please complete the following information):
[✔] Environment
- OS: Windows 10.0.26100 x86_64 (X64)
✔ WebView2: 133.0.3065.69
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.84.1 (e71f9a9a9 2025-01-27)
✔ cargo: 1.84.1 (66221abde 2024-11-19)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
Describe the bug
There appears to be a memory leak when using
webview.evaluate_script()
.During testing, continuous calls to this method result in significant memory growth.
The webview process grows to approximately 870MB while the backend reaches 130MB after 2 million iterations.
Steps To Reproduce
main.rs
:Task Manager
.Expected behavior
The memory usage should remain stable or have minimal growth over time when repeatedly calling
evaluate_script
. Instead, it continuously grows, indicating a memory leak.Screenshots
Platform and Versions (please complete the following information):
[✔] Environment
- OS: Windows 10.0.26100 x86_64 (X64)
✔ WebView2: 133.0.3065.69
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.84.1 (e71f9a9a9 2025-01-27)
✔ cargo: 1.84.1 (66221abde 2024-11-19)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
Additional context
This issue may be the reason for tauri-apps/tauri#12724
The text was updated successfully, but these errors were encountered: