[enhancement](memory) Support try catch bad alloc (#14135)
This commit is contained in:
@ -45,8 +45,9 @@ uint8_t* SystemAllocator::allocate_via_malloc(size_t length) {
|
||||
char buf[64];
|
||||
auto err = fmt::format("fail to allocate mem via posix_memalign, res={}, errmsg={}.", res,
|
||||
strerror_r(res, buf, 64));
|
||||
MemTrackerLimiter::print_log_process_usage(err);
|
||||
LOG(ERROR) << err;
|
||||
if (enable_thread_cache_bad_alloc) throw std::bad_alloc {};
|
||||
MemTrackerLimiter::print_log_process_usage(err);
|
||||
return nullptr;
|
||||
}
|
||||
return (uint8_t*)ptr;
|
||||
|
||||
Reference in New Issue
Block a user