File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
paddle/fluid/memory/allocation Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ void Allocator::Free(Allocation* allocation) { delete allocation; }
36
36
const char * BadAlloc::what () const noexcept { return msg_.c_str (); }
37
37
38
38
void AllocationDeleter::operator ()(Allocation* allocation) const {
39
- allocation->allocator ()->Free (allocation);
39
+ auto * allocator = allocation->allocator ();
40
+ if (allocator) {
41
+ allocator->Free (allocation);
42
+ } else {
43
+ delete allocation; // Compatible for legacy allocation.
44
+ }
40
45
}
41
46
42
47
} // namespace allocation
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ void BufferedAllocator::FreeCache(size_t size) {
41
41
while (!allocations_.empty ()) { // free the largest
42
42
auto it = --allocations_.end ();
43
43
cur += it->second ->size ();
44
+ delete it->second .release ();
44
45
allocations_.erase (it);
45
46
if (cur >= size) return ;
46
47
}
You can’t perform that action at this time.
0 commit comments