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
After the update to 0.18, we've started to observe weird memory behavior in our app, which looks like a memory leak to me.
I've used code from examples/examples/tokio_console.rs to reproduce the issue, it starts jsonrpsee server, registers dummy method and waits. Client sends requests sequentially and receives 405 Status Code.
Server code
use std::net::SocketAddr;
use jsonrpsee::server::ServerBuilder;
use jsonrpsee::RpcModule;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let _ = run_server().await?;
futures::future::pending().await
}
async fn run_server() -> anyhow::Result<SocketAddr> {
let server = ServerBuilder::default().build("127.0.0.1:9944").await?;
let mut module = RpcModule::new(());
//Use for 0.18
//module.register_method("say_hello", |_, _| "lo")?;
module.register_method("say_hello", |_, _| Ok("lo"))?;
let addr = server.local_addr()?;
let handle = server.start(module)?;
// In this example we don't care about doing a stopping the server so let it run forever.
// You may use the `ServerHandle` to shut it down or manage it yourself.
tokio::spawn(handle.stopped());
Ok(addr)
}
Client code
use std::time::Duration;
#[tokio::main]
async fn main() {
tokio::spawn(async {
loop {
let _ = dbg!(reqwest::get("http://127.0.01:9944").await);
tokio::time::sleep(Duration::from_millis(10)).await
}
});
futures::future::pending().await
}
STR
Run server code sample for both: 0.16.2 and 0.18.2 versions of jsonrpsee;
It looks like the issue is in the fact that futures running connections are not dropped.
Connections are inserted here and here BUT not removed in the server's loop here
Summary
After the update to 0.18, we've started to observe weird memory behavior in our app, which looks like a memory leak to me.
I've used code from
examples/examples/tokio_console.rs
to reproduce the issue, it startsjsonrpsee
server, registers dummy method and waits. Client sends requests sequentially and receives 405 Status Code.Server code
Client code
STR
0.16.2
and0.18.2
versions ofjsonrpsee
;Behavior
0.16.2
- memory usage is constant, as expected. See heaptrack profile report0.18.2
- memory usage grows over time. See heaptrack profile reportThe text was updated successfully, but these errors were encountered: