public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: aureliom@crt.com
To: SCroall@staffware.com, geoff.stevens@macro4.com,
	pthreads-win32@sourceware.cygnus.com
Subject: RE: HANDLE leak
Date: Tue, 12 Oct 1999 09:16:00 -0000	[thread overview]
Message-ID: <F931488C3634D11180D700A02461E24502035B37@chitmd03.nt.il.nbgfn.com> (raw)

You should call the routine pthread_detach() or set the
PTHREAD_CREATE_DETACHED attribute.  If you call pthread_join() it will block
your program.  The only disadvantage to detached threads is that you can no
longer call pthread_join().  However, if you never need to call this
function then there is no disadvantage.
 
Aurelio Medina
Bank of America, Distributed Systems Management
Voice:	(312) 234-2105
Fax:	(312) 453-2105
mailto:aureliom@crt.com < mailto:aureliom@crt.com > 
http://netatwork.nbgfn.com/html/gas.html
< http://netatwork.nbgfn.com/html/gas.html > 


	-----Original Message-----
	From:	Steve Croall [SMTP:SCroall@staffware.com]
	Sent:	Tuesday, October 12, 1999 11:05 AM
	To:	'Geoff Stevens'; 'pthreads-win32@sourceware.cygnus.com'
	Subject:	RE: HANDLE leak

	Thanks.  Are there any disadvantages to running the threads
detached?  Is
	there any reason why this is not the default behaviour?  I wouldn't
be
	surprised if that was just the way it was :-)
	 
	Steve.  
	 

	-----Original Message-----
	From: Geoff Stevens [ mailto:geoff.stevens@macro4.com ]
	Sent: 12 October 1999 17:04
	To: 'pthreads-win32@sourceware.cygnus.com'
	Subject: FW: HANDLE leak



	Steve, 

	I think you should either create your threads detached (set
	PTHREAD_CREATE_DETACHED in the attributes) or do a pthread_join for
each of
	them in main().

	At the moment the threads you create are waiting for a join after
	pthread_exit, and their Win32 threads (and thus their handles)
cannot be
	released.

	I'm using detached threads with the same levels of the library and
NT and
	see no increase in handle usage after all my threads have
terminated.

	Best, 
	Geoff Stevens   

	-----Original Message----- 
	From:   Steve Croall [SMTP:SCroall@staffware.com] 
	Sent:   12 October 1999 16:24 
	To:     geoff.stevens@macro4.com 
	Subject:        HANDLE leak 

	The following small program shows the HANDLE count in "Performance
Monitor",

	for the executable when running, increasing at an alarming rate.  Is
this 
	normal or am I not doing something to clear-up?  I am using the
1999-09-17 
	snap-shot on Windows NT 4, service pack 4. 

	#include <stdio.h> 
	#include <stdlib.h> 
	#include <conio.h> 

	#include "pthread.h" 

	void *thrd_func (void *i) 
	{ 
	        Sleep (500); 

	        pthread_exit ((void *) 1); 
	} 

	int main (int argc, char **argv) 
	{ 
	        int             i = 0; 
	        pthread_t       t_id; 

	        while (!_kbhit ()) 
	        { 
	                Sleep (1000); 
	                pthread_create (&t_id, NULL, (void *) thrd_func,
NULL); 
	        } 

	        Sleep (1000); 
	} 


	Regards, 

	        Steve Croall ( SCroall@staffware.com ) 


	Chicago law prohibits eating in a place that is on fire. 

             reply	other threads:[~1999-10-12  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-12  9:16 aureliom [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-10-12  9:06 Steve Croall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F931488C3634D11180D700A02461E24502035B37@chitmd03.nt.il.nbgfn.com \
    --to=aureliom@crt.com \
    --cc=SCroall@staffware.com \
    --cc=geoff.stevens@macro4.com \
    --cc=pthreads-win32@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).