From: Artur Bergman Date: Sun, 21 Apr 2002 13:53:54 +0000 (+0000) Subject: Got the last memory leak in the while(1) { threads->create(sub X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=953932261b0a9c87e3ae16397b725c36b4590fec;p=p5sagit%2Fp5-mst-13.2.git Got the last memory leak in the while(1) { threads->create(sub {})->join() }, now we can loop over a million threads without a problem. Cleared up SVs that should have been mortal but never where. p4raw-id: //depot/perl@16041 --- diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs index 89c19b3..0e19923 100755 --- a/ext/threads/threads.xs +++ b/ext/threads/threads.xs @@ -439,6 +439,7 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param known_threads++; active_threads++; MUTEX_UNLOCK(&create_destruct_mutex); + sv_2mortal(params); return ithread_to_SV(aTHX_ obj, thread, classname, FALSE); } @@ -541,7 +542,7 @@ CODE: if (items > 2) { int i; for(i = 2; i < items ; i++) { - av_push(params, ST(i)); + av_push(params, SvREFCNT_inc(ST(i))); } } ST(0) = sv_2mortal(Perl_ithread_create(aTHX_ Nullsv, classname, function_to_call, newRV_noinc((SV*) params)));