chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #1367: Possible memory leak related to mutexes


From: Chicken Trac
Subject: [Chicken-janitors] #1367: Possible memory leak related to mutexes
Date: Thu, 04 May 2017 15:57:09 -0000

#1367: Possible memory leak related to mutexes
-------------------------------+--------------------------------
 Reporter:  megane             |                 Owner:
     Type:  defect             |                Status:  new
 Priority:  not urgent at all  |             Milestone:  someday
Component:  core libraries     |               Version:  4.12.0
 Keywords:  srfi-18            |  Estimated difficulty:
-------------------------------+--------------------------------
 The following program eats up all the memory fairly quickly.

 Two methods to make it not do that:
 1. Comment out the `mutex-lock!` and `mutex-unlock!` calls, or
 2. uncomment the `(gc)` call.

 Tested with 4.12.

 {{{#!scheme
 (use (only srfi-18 mutex-lock! mutex-unlock! thread-yield! make-thread
 thread-start!))
 (use (only extras format))

 (define (make-philosopher name mtx)
   (thread-start!
    (make-thread
     (lambda ()
       (mutex-lock! mtx)
       ;; (print name " eating" mtx)
       (mutex-unlock! mtx)
       ;(gc) ; <- Uncommenting this seems to stop unbounded growth
       (make-philosopher name mtx)))))

 (let ((mtx-food (make-mutex 'food)))
   (let lp ((i 0))
     (when (< i 5)
       (print "start philosopher-" i)
       (make-philosopher (string->symbol (format "philosopher-~a" i)) mtx-
 food)
       (lp (add1 i))))
   (let lp ()
     (thread-sleep! 100)
     (lp)))

 }}}

--
Ticket URL: <https://bugs.call-cc.org/ticket/1367>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]