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

Fix CPU memory leak due to external weights not getting memory unmapped when using non-CPU EP. #15040

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

pranavsharma
Copy link
Contributor

@pranavsharma pranavsharma commented Mar 14, 2023

Description

Fix CPU memory leak due to external weights not getting memory unmapped when using non-CPU EP.

Sample program that creates a session in a loop of 5
Before (1.14.1 release)
image

After
image

Motivation and Context

Fixes #14466 and a bunch of others

@@ -161,9 +161,11 @@ static common::Status DeserializeTensorProto(const Env& env, const std::basic_st
}

OrtCallback ext_data_deleter;
ScopedOrtCallbackInvoker scoped_ort_callback_invoker;
if (utils::HasExternalData(tensor_proto)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use std::optional to avoid the changes to callback.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, but in general RAII classes should also have a default constructor (like unique_ptr, shared_ptr, scoped_ptr) and a way to either reset its contents or copy/move them. Hence the change to callback.h.

Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

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

Successfully merging this pull request may close these issues.

Massive Memory Leak c# DirectML
2 participants