When threads are added to boost::thread_group like:
boost::thread_group my_threads;
boost::thread *t = new boost::thread( &someFunc );
my_threads.add_thread(th);
all the created boost::thread objects are deleted only when my_threads object is out of scope. But my program main thread spawns a lot of threads while execution. So if about 50 threads are already done, about 1,5Gb of memory is used by program and this memory is freed only on main process termination.
The question is: How to delete these boost::thread object when thread function is finished ?!