tags:

views:

184

answers:

2

In one of the multithreaded Linux application, the application quits without deleting the thread. Will this cause any thread resource leakage. If this application is launched many times during the course of the day, will the system crash?

+3  A: 

The kernel generally cleans up a process's resources (open files, threads, allocated memory, etc.) when it exits, so I don't think you need to worry. Although it could be stylistically better to delete the thread explicitly, possibly depending on your preferred coding style.

David Zaslavsky
+4  A: 

For the most part, all resources used by a program are cleaned up when the program exists. There are a few exceptions (partial list here, no doubt):

  • files created (duh!)
  • TCP sockets may take several minutes after program exit to fully clean up (e.g., TIME_WAIT sockets)
  • SysV shared memory, semaphores, and message queues (clean up manually using ipcs/ipcrm)

Other than that, pretty much everything is cleaned up. Including threads.

Naturally, you should test this.

derobert
+1, its better to know what those threads were actually doing.
Tim Post