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

rust web服务内存占用过高不释放问题 #182

Open
zqlpaopao opened this issue Nov 22, 2023 · 1 comment
Open

rust web服务内存占用过高不释放问题 #182

zqlpaopao opened this issue Nov 22, 2023 · 1 comment

Comments

@zqlpaopao
Copy link

程序是actix_web的,我的程序启动的时候14MB的内存,请求接口会用800MB+的内存执行一些操作。然而,后续接口返回大量数据后程序中的800MB+尚未回收。这是什么原因?该语言的一些设置功能,或者有没有像PPROF这样的有用工具可以检测内存溢出

然后发现 大多web框架都有这个问题
image
image

use actix_web::{get, HttpResponse, Responder};
use crate::controller::link_inspection::check::LinkInspection;
use std::collections::HashMap;
#[get("/check")]
async fn check() -> impl Responder {

// 启动堆分析器
// let res = LinkInspection::new().doing().await;
// match res {
//     Ok(response) => HttpResponse::Ok().json(response),
//     Err(error) => HttpResponse::InternalServerError().body(error.to_string()),
// }
let mut  h: HashMap<i64,i64> = HashMap::with_capacity(100000);
test(&mut h).await;

HttpResponse::InternalServerError().body(format!("{:?}", h))
}

async fn test (h : &mut HashMap<i64,i64>){

// tokio::time::sleep(tokio::time::Duration::from_secs(25)).await;
println!("start");
for v in 0..1000000{
    h.insert(v,v);
}
}
@zqlpaopao
Copy link
Author

具体案例 查看 actix/actix-web#3198

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

No branches or pull requests

1 participant