﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
1367	Possible memory leak related to mutexes	megane		"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)))

}}}"	defect	closed	not urgent at all	4.13.0	core libraries	4.12.0	fixed	srfi-18		insane
