Skip to content
Snippets Groups Projects
Unverified Commit 23447d29 authored by yzhao's avatar yzhao Committed by GitHub
Browse files

Add BPFStackTable::free_symcache() to free the symbol cache for an PID (#3371)

This is useful when BPFStackTable is used by a long running program to
limit the memory usage, by removing the cached symbols of an exited
process.
parent cda7acdb
No related branches found
No related tags found
No related merge requests found
......@@ -274,6 +274,14 @@ BPFStackTable::~BPFStackTable() {
bcc_free_symcache(it.second, it.first);
}
void BPFStackTable::free_symcache(int pid) {
auto iter = pid_sym_.find(pid);
if (iter != pid_sym_.end()) {
bcc_free_symcache(iter->second, iter->first);
pid_sym_.erase(iter);
}
}
void BPFStackTable::clear_table_non_atomic() {
for (int i = 0; size_t(i) < capacity(); i++) {
remove(&i);
......
......@@ -378,6 +378,7 @@ class BPFStackTable : public BPFTableBase<int, stacktrace_t> {
BPFStackTable(BPFStackTable&& that);
~BPFStackTable();
void free_symcache(int pid);
void clear_table_non_atomic();
std::vector<uintptr_t> get_stack_addr(int stack_id);
std::vector<std::string> get_stack_symbol(int stack_id, int pid);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment