[gambit-list] gambit-c 4.6.0, cairo and valgrind.

Marco Benelli mbenelli at yahoo.com
Wed Mar 24 22:32:42 EDT 2010


From: Vladimir Konrad <v.konrad at lse.ac.uk>
> [...]
> Cairo does do reference counting, but it 
> is not automatic - user is responsible to call destroy when necessary (AFAIK - 
> the examples I saw show this).
> [...]
> I have attached 2 minimalist test 
> programs, one is in c one in gambit scheme (both do essentially the same 
> thing.
> (you would need to change path to .png file for them to 
> work).


I have done some tests, and I haven't observed  any memory leak.
My guess is that the memory "lost" is spent to allocate binding's symbols, that are permanent objects.

I've also added enums and automatic decrement of reference counters, so the code I've tested looks like:

(load "../cairo")

(define image_path "img.png")

(let loop ((counter 1000))
  (if (zero? counter)
      #f
      (let* ([imsur_1 (cairo-image-surface-create-from-png image_path)]
              [imsur_2 (cairo-image-surface-create-from-png image_path)]
              [cr (cairo-create imsur_1)])
        (cairo-set-operator cr CAIRO_OPERATOR_XOR)
        (cairo-set-source-surface cr imsur_2 0.0 0.0)
        (cairo-paint cr)
        (loop (- counter 1)))))


New version of cairo bindings is on dumping grounds.

--marco



More information about the Gambit-list mailing list