yiguolei commented on code in PR #14135: URL: https://github.com/apache/doris/pull/14135#discussion_r1018605314
########## be/src/runtime/thread_context.h: ########## @@ -299,33 +300,87 @@ class StopCheckThreadMemTrackerLimit { tracker->transfer_to( \ size, doris::thread_context()->_thread_mem_tracker_mgr->limiter_mem_tracker_raw()) +// Consider catching other memory errors, such as memset failure, etc. +#define RETURN_IF_CATCH_BAD_ALLOC(stmt) \ + do { \ + doris::thread_context()->_thread_mem_tracker_mgr->clear_exceed_mem_limit_msg(); \ + if (doris::thread_context()->enable_thread_cache_bad_alloc) { \ + try { \ + { stmt; } \ + } catch (std::bad_alloc const&) { \ + return Status::MemoryLimitExceeded( \ + fmt::format("PreCatch Bad Alloc: {}", \ + doris::thread_context() \ + ->_thread_mem_tracker_mgr->exceed_mem_limit_msg())); \ + } \ + } else { \ + try { \ + doris::thread_context()->enable_thread_cache_bad_alloc = true; \ Review Comment: using Defer defer here. because if user add a return stmt in params the context is not set back. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org