pthread programming eats up resources (My or FreeBSD's fault?)

Ed Maste emaste at freebsd.org
Wed Feb 19 15:53:05 UTC 2014


On 19 February 2014 10:08, Erich Dollansky <erichsfreebsdlist at alogt.com> wrote:
> Hi,
>
> as I understand your program, it creates 1000 threads, waits a but and
> then starts again creating 1000 threads until something kill it.
>
> From my point of view, your program depends very much on the default
> settings of the environment. If the environment allows the immediate
> execution of the new thread, you will never get many threads.
> Otherwise, the number of threads hanging around could add up. It also
> depends on the number of CPUs/cores your system has.

> But your are right, it should not crash on a modern machine but it
> still could use some amount of memory.

Andre's second example program demonstrates the problem as well.  It
calls pthread_join() for each of the created threads, so should not be
able to leave them around.


More information about the freebsd-threads mailing list