racket/collects/tests/racket/place-channel-limits.rkt
Matthew Flatt 5c0956d7b1 more memory accounting fixes for places
Fix memory accounting to detect when messages pile up in a
place channel and when shared values (such as the result of
`make-shared-bytes') pile up. Also fix problems where a GC
or free-page purge needs to be triggered.

The implementation causes a minor API change, which is that
a place channel sent multiple times as a message generates
values that are `equal?' but no longer eq?'.

Closes PR 12273

[Do not merge to 5.2]
2011-10-11 11:26:11 -06:00

25 lines
715 B
Racket

#lang racket
(require racket/place)
;; Check the interaction of custodian memory limits with
;; * allocating shared arrays, and
;; * putting messages into an channel with no receiver
(define (check shared?)
(for ([i 20])
(printf "iter ~a\n" i)
(let ([c (make-custodian)])
(custodian-limit-memory c (* 1024 1024 10) c)
(parameterize ([current-custodian c])
(thread-wait
(thread
(lambda ()
(define-values (a b) (place-channel))
(for/fold ([v 0]) ([i (in-range 999999999)])
(if shared?
(cons (make-shared-bytes 1024) v)
(place-channel-put b (list 1 2 3 4)))))))))))
(check #t)
(check #t)