[racket] Memory and delimited continuations

From: nicolas.oury at gmail.com (nicolas.oury at gmail.com)
Date: Thu Oct 27 14:57:57 EDT 2011

Dear all,

Following on my memory leak problem, I managed to minimise my program.
And I still don't understand why it leaks.

Here is a minimised example:

(define prompt1 (make-continuation-prompt-tag 'p1))
(define prompt2 (make-continuation-prompt-tag 'p2))

(define (capture-and-abort prompt-tag)
  (call-with-composable-continuation
   (lambda (k) (abort-current-continuation prompt-tag k))
      prompt-tag))

(define (test i)
   (call-with-continuation-prompt
     (lambda ()
       (call-with-continuation-prompt
        (lambda()
          (for ((j i))
                (capture-and-abort prompt1)
                (capture-and-abort prompt2)))
        prompt2))
       prompt1))

(test 100000)

Calling test with any number 100 000 or higher will allocate memory very
fast.
What is the reason for that and how can I solve this?

Best regards,

Nicolas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111027/5c16267c/attachment.html>

Posted on the users mailing list.