[plt-scheme] draw-bitmap causes memory leak?

From: Tord Svensson (tord at lysator.liu.se)
Date: Wed Nov 26 05:09:30 EST 2003

There seems to be a memory leak in draw-bitmap when using masks. I've
narrowed it down to the following small test case:

(define black (make-object color% 0 0 0))

(define image (make-object bitmap% "image.bmp" 'bmp #f))
(define image-mask (make-object bitmap% "image-mask.bmp" 'bmp #f))

(define simple-canvas
  (class canvas%

    (init-field parent)

    (define (on-paint)
      (define dc (send this get-dc))
      (send dc draw-bitmap image 0 0 'solid black image-mask))

 (super-instantiate (parent))))

(define win (make-object frame% "Some frame"))
(define canvas (make-object simple-canvas win))

(send win resize 300 300)
(send win show #t)

(define runner
  (thread (lambda ()
            (let loop ()
              (send canvas on-paint)
              (sleep 0.02)

When running the above with DrScheme 205 (on Solaris, with or without
debugging or profiling) the memory consumption rapidly grows and the
machine starts to swap heavily. So, there seems to be a memory leak,
either in the MrED Graphical Toolbox or the underlying WxWindows code...

Furthermore the get/set-loaded-mask methods do not seem to have any
affect on the problem. However, when using gif:s, instead of bmp:s or
jpg:s, the leak vanishes.

To me, this seems like a memory leak, or am I missing something?

--Tord Svensson

Posted on the users mailing list.