Pithikos/C-Thread-Pool

Doesn't release memory until job queue is empty?

rapier1 opened this issue · 1 comments

I have an application using Thread Pool that will often result in job queues of more than 25,000 jobs. This is expected and the delay in processing the jobs isn't a problem. However, the memory consumed by the queue doesn't seem to be released once the job is executed. At peak the resident memory of the application might reach 1GB when the job queue is peaking. However, when the job_queue reaches zero the resident memory is largely cleared.

I've run everything through valgrind multiple times and it's not indicating any memory leaks when the application shuts down gracefully. When I put in a dummy call back that keeps the queue at a minimum size the memory consumption is pretty low. The only thing that seems related to the total memory consumption is the job queue length. That the resident memory clears once the queue is empty is odd to me. Do you have any suggestions?

Thanks

I guess you are referring to the 'jobqueue_destroy' function
This function is only used in 'thpool_destroy', and the release queue should only be called when the thread pool is released.
Here is the author's explanation