print stack memory allocation history
This commit is contained in:
parent
c95a7ac62c
commit
392907c24e
@ -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_;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user