Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Strange memory usage #2588

Closed
1 task
ConsoleC137 opened this issue Feb 11, 2024 · 1 comment
Closed
1 task

Strange memory usage #2588

ConsoleC137 opened this issue Feb 11, 2024 · 1 comment

Comments

@ConsoleC137
Copy link

  • I have looked for existing issues (including closed) about this

Bug Report

Version

axum v0.7.4
axum-core v0.4.3

Platform

Linux [..] 6.7.2-arch1-2 #1 SMP PREEMPT_DYNAMIC Wed, 31 Jan 2024 09:22:15 +0000 x86_64 GNU/Linux

Crates

axum = "0.7.4"
tokio = { version = "1.36.0", features = ["full"] }

Description

simplescreenrecorder-2024-02-07_03.49.11.webm
Greetings, everyone.
While testing axum, I noticed a strange feature: every time I ran wrk, the memory consumption increased. In the video above, each server outputs "Hello, World!". As you can see axum's memory consumption is increasing, while actix-web behaves quite predictably. I also tried adding an asynchronous wait to emulate an I/O operation, but this had no effect on memory consumption. At first I thought it looked like a memory leak, but I didn't jump to conclusions and continued testing. I noticed one detail: axum returns memory, but in my case it happened only after a few hours. I'm afraid that in production the application might crash with an OOM error.

My code:

use axum::{response::Html, routing::get, Router};

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(handler));

    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    println!("listening on {}", listener.local_addr().unwrap());
    axum::serve(listener, app).await.unwrap();
}

async fn handler() -> Html<&'static str> {
    // optional
    tokio::time::sleep(std::time::Duration::from_millis(50)).await;

    Html("<h1>Hello, World!</h1>")
}

Please let me know if I have made any errors in the design of the Bug Report.

@Kav91
Copy link

Kav91 commented Feb 12, 2024

Started noticing this as well, memory increasing by ~100-200kb per request.
Very similar behavior as mentioned here: #1546

@tokio-rs tokio-rs locked and limited conversation to collaborators Feb 12, 2024
@davidpdrsn davidpdrsn converted this issue into discussion #2589 Feb 12, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants