-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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: Release CPU/GPU memory at the end of the Program #3534
Conversation
@@ -45,4 +45,8 @@ TEST(Gather, GatherData) { | |||
|
|||
for (int i = 0; i < 4; ++i) EXPECT_EQ(p_output[i], i + 4); | |||
for (int i = 4; i < 8; ++i) EXPECT_EQ(p_output[i], i - 4); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zchen0211 return tensor memory back to buddy allocator for free.
paddle/memory/memory.cc
Outdated
|
||
BuddyAllocator* GetCPUBuddyAllocator() { | ||
static std::unique_ptr<BuddyAllocator, void (*)(BuddyAllocator*)> a{ | ||
nullptr, [](BuddyAllocator* p) { delete p; }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why here need to pass a lambda function, unique_ptr will delete the pointer automaticlly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Deleter could be default one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
After unit test is passed, release memory!
fix #3536
fix #3537