提交 392907c2 编写于 作者: O obdev 提交者: ob-robot

print stack memory allocation history

上级 c95a7ac6
......@@ -145,6 +145,7 @@ void StackMgr::insert(ObStackHeader *header)
header->next_ = dummy_.next_;
dummy_.next_->prev_ = header;
dummy_.next_ = header;
add_flow(header, 1);
mutex_.unlock();
}
}
......@@ -157,9 +158,22 @@ void StackMgr::erase(ObStackHeader *header)
header->prev_->next_ = header->next_;
header->next_->prev_ = header->prev_;
header->prev_ = header->next_ = header;
add_flow(header, 0);
mutex_.unlock();
}
}
void StackMgr::add_flow(ObStackHeader *header, bool is_alloc)
{
int ret = databuff_printf(flow_print_buf_, sizeof(flow_print_buf_), flow_print_pos_,
"%p %d %ld %ld %s\n", header, is_alloc, header->size_, GETTID(), lbt());
if (OB_SUCC(ret) && flow_print_pos_ > sizeof(flow_print_buf_)/2) {
common::allow_next_syslog();
_LOG_INFO("DUMP STACK FLOW:\n%.*s", static_cast<int32_t>(flow_print_pos_), flow_print_buf_);
flow_print_pos_ = 0;
}
}
} // lib
} // oceanbase
......@@ -54,6 +54,7 @@ class StackMgr
friend class ObMemoryCutter;
public:
StackMgr()
: flow_print_pos_(0)
{
dummy_.prev_ = dummy_.next_ = &dummy_;
}
......@@ -61,8 +62,12 @@ public:
void erase(ObStackHeader *);
ObStackHeader *begin() { return dummy_.next_; }
ObStackHeader *end() { return &dummy_; }
private:
void add_flow(ObStackHeader *header, bool is_alloc);
private:
lib::ObMutex mutex_;
char flow_print_buf_[8192];
int64_t flow_print_pos_;
ObStackHeader dummy_;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册