guile-gtk-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

memory leaks in canvas?


From: Greg Troxel
Subject: memory leaks in canvas?
Date: 03 Mar 2005 17:06:59 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

I have written a program using guile-gnome (0.98 for now).  It creates
a canvas, and creates rectanges with text (in a group) for nodes in a
network, and would like to draw lines for links.   Then, nodes and
lines are moved to make lengths be reasonable for the link metrics.

The nodes I actually move (the group that holds the rectangle and
text).  The lines are filled paths, since lines don't work yet.

I haven't figured out how to move the bezier path (both ends), since
that involves changing everything (really setting a new def I guess).
So I hide it and create another.

My X server runs out of memory, and the issue seems to be pixmaps.
Plus, the guile process grows to 150 MB.  This is even with explicit
gc every 5s.   I have around 15 nodes and 50 links, and I update
positions once a second.   The program runs out of x server memory in
about 15 minutes.

So, I suspect that there is a memory leak and that when the goops
objects below get garbage collected that the underlying canvas objects
do not get deleted and freed (freeing resources in X server and
guile).

Can anyone tell me how to destroy an object, other than losing a
reference and waiting for gc?

I suppose I can just make a new def, or reset this one and refill it.
Does that sound reasonable?


My line drawing function:

;; utility function that doesn't belong here
(define (draw-line x1 y1 x2 y2 width parent)
  (let*
      ((def (make <gnome-canvas-path-def>))
       (bezier (make <gnome-canvas-bpath>
                 #:parent parent
                 #:fill-color "black"
                 #:width-pixels 20))
       (theta (atan (- y2 y1) (- x2 x1)))
       (right (+ theta 1.5707963267949))
       (incx (* width (cos right)))
       (incy (* width (sin right))))

    (move bezier 0 0)                   ;why?
    (reset def)                         ;why?
    (moveto def x1 y1)
    (lineto def x2 y2)
    (lineto def (+ x2 incx) (+ y2 incy))
    (lineto def (+ x1 incx) (+ y1 incy))
    (closepath def)
    (set-path-def bezier def)
    (gnome-canvas-item-lower-to-bottom bezier)
    ;;(format #t "bezier ~A ~A ~A ~A parent ~A\n" x1 y1 x2 y2 parent)
    bezier))

-- 
        Greg Troxel <address@hidden>
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]