<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: pthread_detach question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370330#M713680</link>
    <description>It seems that the reuse of a thread stack is one pthread_create behind the pthread_exit.  I modified the test to print the address of the stack and to run a couple of parallel threads.&lt;BR /&gt;Each of the allocated stack address ranges was eventually reused.  The stack of the most recently exited thread was not reused in the subsequent call to pthread_create.</description>
    <pubDate>Wed, 08 Sep 2004 14:03:45 GMT</pubDate>
    <dc:creator>Mike Stroyan</dc:creator>
    <dc:date>2004-09-08T14:03:45Z</dc:date>
    <item>
      <title>pthread_detach question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370327#M713677</link>
      <description>Say I have a thread "tid" and I call pthread_detach(tid).  Then in the thread itself I call pthread_exit.  If I watch the process in glance and top, when the thread exits, since it's detached, shouldn't the memory (RSS/VSS in glance and SIZE and RES in top) go DOWN?  I keep watching it and the memory usage doesn't go down and when I start another thread, the memory usage increases.  This is 11.11 by the way.&lt;BR /&gt; &lt;BR /&gt;This is my test program:&lt;BR /&gt;&lt;BR /&gt;#define _MULTI_THREADED&lt;BR /&gt;#include &lt;PTHREAD.H&gt;&lt;BR /&gt;#include &lt;ERRNO.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;void *threadfunc(void *threadid)&lt;BR /&gt;{&lt;BR /&gt;   void *status;&lt;BR /&gt;&lt;BR /&gt;   printf("In thread\n");&lt;BR /&gt;   sleep(10);&lt;BR /&gt;   printf("Exit thread\n");&lt;BR /&gt;   pthread_exit(&amp;amp;status);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;   pthread_t      thread;&lt;BR /&gt;   int            rc, i;&lt;BR /&gt;&lt;BR /&gt;   printf("Start main()\n");&lt;BR /&gt;&lt;BR /&gt;   for (i = 0; i &amp;lt; 2; i++) {&lt;BR /&gt;      rc = pthread_create(&amp;amp;thread, NULL, threadfunc, NULL);&lt;BR /&gt;      printf("pthread_create returned %d\n", rc);&lt;BR /&gt;      rc = pthread_detach(thread);&lt;BR /&gt;      printf("pthread_detach returned %d\n", rc);&lt;BR /&gt;      sleep(30);&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;   printf("exit program\n");&lt;BR /&gt;   exit(0);&lt;BR /&gt;}&lt;/STDIO.H&gt;&lt;/ERRNO.H&gt;&lt;/PTHREAD.H&gt;</description>
      <pubDate>Wed, 01 Sep 2004 16:12:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370327#M713677</guid>
      <dc:creator>Blanche Healy</dc:creator>
      <dc:date>2004-09-01T16:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: pthread_detach question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370328#M713678</link>
      <description>Hi Blanche,&lt;BR /&gt;&lt;BR /&gt;It is printf() per thread buffer</description>
      <pubDate>Sun, 05 Sep 2004 15:39:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370328#M713678</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2004-09-05T15:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: pthread_detach question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370329#M713679</link>
      <description>I'm sorry??  I don't understand.  I do know that if I take the above code and compile and run on a freeBSD system that the memory never budges.  It doesn't go down when the thread exist but it also does not go up when a new thread is created.</description>
      <pubDate>Wed, 08 Sep 2004 10:33:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370329#M713679</guid>
      <dc:creator>Blanche Healy</dc:creator>
      <dc:date>2004-09-08T10:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: pthread_detach question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370330#M713680</link>
      <description>It seems that the reuse of a thread stack is one pthread_create behind the pthread_exit.  I modified the test to print the address of the stack and to run a couple of parallel threads.&lt;BR /&gt;Each of the allocated stack address ranges was eventually reused.  The stack of the most recently exited thread was not reused in the subsequent call to pthread_create.</description>
      <pubDate>Wed, 08 Sep 2004 14:03:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370330#M713680</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2004-09-08T14:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: pthread_detach question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370331#M713681</link>
      <description>Hmm... OK.  So if I increase "i" to some big number and just let it run, after a while, my memory numbers should stablize since the memory for the old threads are being re-used right?</description>
      <pubDate>Sat, 11 Sep 2004 16:09:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pthread-detach-question/m-p/3370331#M713681</guid>
      <dc:creator>Blanche Healy</dc:creator>
      <dc:date>2004-09-11T16:09:07Z</dc:date>
    </item>
  </channel>
</rss>

