-
Notifications
You must be signed in to change notification settings - Fork 461
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
重复刷新模型造成的内存泄露问题 #2511
Comments
如果你是每一次都要加载模型,建议把加载模型的操作放在子进程里,这样进程结束,占用资源会自动释放 |
FastDeploy是一个很棒的框架,我在尝试将这个框架应用到真实的生产环境中。如果把加载模型的操作放在子进程会造成不必要的开销和加深算法的复杂度,能否实现在同进程主动释放内存 |
在你的代码里,是会循环调用这一行是吗 也许你可以试一下将model的声明也放在一个作用域内,例如
测试看下是否可以在出作用域后自动释放 |
十分感谢您的解答,我的代码会在特定情况下重复调用多次 |
温馨提示:根据社区不完全统计,按照模板提问,可以加快回复和解决问题的速度
环境
【FastDeploy版本】: deploy自己编译
【编译命令】export ENABLE_ORT_BACKEND = OFF
export ENABLE_PADDLE_BACKEND = OFF
export ENABLE_OPENVINO_BACKEND = OFF
export ENABLE_VISION = ON
export ENABLE_TEXT = OFF
export ENABLE_TRT_BACKEND = OFF
export WITH_GPU = OFF
【系统平台】: Windows 11
【硬件】: 笔记本 intel i7-1260p
【编译语言】:C++
问题日志及出现问题的操作流程
由于工程要求,每次刷新相机之后都需要重新刷新一次AI模型。经过测试发现,如果重复调用多次模型初始化函数,会造成内存泄漏,每隔10s~20s会泄露0.3M。下面是我的初始化函数
bool OcrModel::InitModel(OcrModelConfig& config) {
// 将 GBK 路径转换为 UTF-8 路径
std::string model_dir = config.strNetPath;
}
The text was updated successfully, but these errors were encountered: