I am developing a small client-server database system using Linux and C with Pthreads on the server side. Each request from the client is processed by a short-lived handler thread that accesses the database and returns data to the client.
My question involves dynamic memory allocation. Each program thread builds internal data structures using repeated calls to malloc(). After the thread terminates I assume this memory is de-referenced and left intact on the heap.
Should the thread free this memory explicitly after use? If so, what would be the consequences of not doing so?
Start Free Trial