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

[core] On Linux try return not used memory to system on compile model destructor #27534

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/inference/src/cpp/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "openvino/runtime/icompiled_model.hpp"
#include "openvino/runtime/properties.hpp"

#if defined(OPENVINO_GNU_LIBC) && !defined(__ANDROID__)
# include <malloc.h>
#endif

#define OV_COMPILED_MODEL_CALL_STATEMENT(...) \
if (_impl == nullptr) \
OPENVINO_THROW("CompiledModel was not initialized."); \
Expand All @@ -23,6 +27,12 @@ namespace ov {

CompiledModel::~CompiledModel() {
_impl = {};
#if defined(OPENVINO_GNU_LIBC) && !defined(__ANDROID__)
// Linux memory margent doesn't return system memory immediate after release.
// It depends on memory chunk size and allocation history.
// Try return memory from a process to system now to reduce memory usage and not wait to the end of the process.
malloc_trim(0);
#endif
}

CompiledModel::CompiledModel(const std::shared_ptr<ov::ICompiledModel>& impl, const std::shared_ptr<void>& so)
Expand Down
Loading