Community
cancel
Showing results for 
Search instead for 
Did you mean: 
mdprice
Beginner
54 Views

scalable_malloc/free after threads are terminated

What happens in to the memory in this scenario?
  1. Memory allocated in thread 1 with scalable_malloc.
  2. Thread 1 terminated.
  3. Thread 2 started.
  4. Thread 2 calls scalable_free on data.
  5. Thread 2 allocates more memory using scalable_malloc.
What I'm observing is that the memory usage is growing in this scenario, whereas when I use malloc/free it doesn't. What has happened is that we have some code that when a connection goes down it kills the worker threads but does not clean up all of the resources. Now when the connection comes back up it restarts the workers and they will clean up the resouces and then allocate what they need.

I have debugged in making sure that mallocThreadShutdownNotification is correctly being called ;)
0 Kudos
1 Reply
Alexey_K_Intel3
Employee
54 Views

If a thread was shut down nicely (and not just killed),the memory it had taken should be reused, though not necessarily immediately. Possibly the problem you see might be partially caused by different allocation sizes requested by the first and the second threads, as the TBB allocator separates memory pools (bins) for different sizes.

If you have a test case that exhibits the problem, I would appreciate if you submit it here.

Reply