Address sanitizer use a lot of memory with pthread of this code:
---
#include <vector>
#include <iostream>
#include <chrono>
#include <thread>
using namespace std;
void thread_main(int thread_id) {
cout << thread_id << endl;
this_thread::sleep_for(chrono::milliseconds(5000));
}
int main() {
vector<shared_ptr<thread>> thread_list;
for (int i=0; i<200; i++) {
thread_list.push_back(make_shared<thread>(thread_main, i));
}
for (auto t: thread_list) {
t->join();
}
thread_list.clear();
return 0;
}
---
before add -fsanitize=address it used 1.6mb, after add it used 270.5mb.
this code just simply create 200 threads, I have no idea why it will
use so much.
GCC version is "gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)",
from rhel 6 devtoolset.
Please let me known if you found anything about this, thanks.
regard.
---
ownssh
ownsshaim@xxxxxxx