-
Notifications
You must be signed in to change notification settings - Fork 8k
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
fix memory leak #10441
fix memory leak #10441
Conversation
Thanks for your contribution! |
Thank you for your contribution, can you provide the procedure to reproduce the memory leak for us to validate the effectiveness of this PR. |
Before I provide the procedure to reproduce the memory leak. Let's go to the code itself. StructureTableRecognizer *table_model_ = nullptr;
StructureLayoutRecognizer *layout_model_ = nullptr; if (FLAGS_layout) {
this->layout_model_ = new StructureLayoutRecognizer(
FLAGS_layout_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, FLAGS_gpu_mem,
FLAGS_cpu_threads, FLAGS_enable_mkldnn, FLAGS_layout_dict_path,
FLAGS_use_tensorrt, FLAGS_precision, FLAGS_layout_score_threshold,
FLAGS_layout_nms_threshold);
}
if (FLAGS_table) {
this->table_model_ = new StructureTableRecognizer(
FLAGS_table_model_dir, FLAGS_use_gpu, FLAGS_gpu_id, FLAGS_gpu_mem,
FLAGS_cpu_threads, FLAGS_enable_mkldnn, FLAGS_table_char_dict_path,
FLAGS_use_tensorrt, FLAGS_precision, FLAGS_table_batch_num,
FLAGS_table_max_len, FLAGS_merge_no_span_structure);
} PaddleStructure::~PaddleStructure() {
if (this->table_model_ != nullptr) {
delete this->table_model_;
}
} Just like the variable table_model_, layout_model_ is a private member of PaddleStructure. They are all initialized in the constructor. But only table_model_ was deleted in the destructor. There will be a memory leak, If the FLAGS_layout was true. |
Thanks for your contribution, can you submit this PR to the dygraph branch? |
* fix memory leak * update: Using smart pointers instead of raw pointers
A new PR is added #10593, TBR. |
1. 跟进 [PaddleOCR #10441](PaddlePaddle/PaddleOCR#10441) - 使用智能指针代替原始指针 - 修复 detector_ classifier_ recognizer_ 可能造成的内存泄漏 2. 跟进 [PaddleOCR #10512](PaddlePaddle/PaddleOCR#10512) - 修复时间记录的初始化过程 3. 格式化代码,补充部分注释
No description provided.