home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 263,910 of 264,096   
   Dan Cross to arne@vajhoej.dk   
   Re: more CMA   
   05 Dec 25 17:15:21   
   
   From: cross@spitfire.i.gajendra.net   
      
   In article <69320352$0$673$14726298@news.sunsite.dk>,   
   Arne Vajhøj   wrote:   
   >On 12/4/2025 2:12 PM, Arne Vajhøj wrote:   
   >> On 12/4/2025 1:29 PM, Simon Clubley wrote:   
   >>> On 2025-12-04, Arne Vajhøj  wrote:   
   >>>>   
   >>>> A sequence of:   
   >>>>   
   >>>> cma_thread_create   
   >>>> cma_mutex_lock   
   >>>> cma_mutex_unlock   
   >>>> cma_thread_join   
   >>>>   
   >>>> and after a little over 10000 iterations:   
   >>>>   
   >>>> %SYSTEM-F-INSFMEM, insufficient dynamic memory   
   >>>> %TRACE-F-NOMSG, Message number 00098054   
   >>>> %TRACE-I-NOMSG, Message number 00098043   
   >>>>   
   >>>   
   >>> Resource leak ?   
   >>   
   >> Definitely.   
   >>   
   >> But the code is rather simple.   
   >>   
   >> Shortest reproducer:   
   >>   
   >> #include    
   >> #include    
   >>   
   >> #include    
   >> #include    
   >>   
   >> void *run(void *p)   
   >> {   
   >>      if(p != NULL) printf("arg pointer = %p\n", p);   
   >>      return NULL;   
   >> }   
   >>   
   >> int main()   
   >> {   
   >>      cma_t_thread t;   
   >>      cma_t_exit_status stat;   
   >>      void *p;   
   >>      cma_init();   
   >>      int n = 0;   
   >>      while(1)   
   >>      {   
   >>          cma_thread_create(&t, &cma_c_null, run, NULL);   
   >>          cma_thread_join(&t, &stat, &p);   
   >   
   >Insert:   
   >   
   >cma_thread_detach(&t);   
   >   
   >and memory gets freed.   
   >   
   >I don't know if this is intentional.   
      
   It appears so.  From the extant documentation I could find about   
   CMA threads, in the description of, `cma_thread_create`:   
      
   |The thread object exists until the cma_thread_detach routine is   
   |called **and** the thread terminates, whichever occurs last.   
      
   [Emphasis added; note the "and" there.]   
      
   Source: https://alpha-supernova.dev.filibeto.org/lib/rel/4.0B/HT   
   L/AA-Q2DPC-TKT1_html/thrd0321.html#cma_thread_create_46   
      
   >Usually join is sufficient.   
      
   With pthreads, yes.  Evidently not with CMA.   
      
   Why bother with CMA, anyway?  Just use pthreads?   
      
   	- Dan C.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca