views:

19

answers:

0

Okay: I'm on a linux system, so if you are windows I'm sure you can figure out how to do the equivalent of some of the actions I describe below

Create 'test.svg' as such:

<svg>
   <circle cx="100" cy="100" r="100"/>
</svg>

Now create this little ruby script:

#!/usr/bin/env ruby
require 'gtk2'
Gtk::init
pixbuf = Gdk::Pixbuf.new "test.svg"
Gtk::Window.new.add(image = Gtk::Image.new(pixbuf)).show_all
Gtk::timeout_add(1000) do
   pixbuf = Gdk::Pixbuf.new "test.svg"
   image.pixbuf = pixbuf
   true
end
Gtk::main

All this script does is reload and display the svg file. Go ahead and run the script as a background process and then run:

watch -n 1 ps -o rss -p <pid>

You'll notice a fairly significant memory leak here. Also, if you change the svg circle definition to:

<circle cx="400" cy="400" r="400"/>

You'll notice the memory leak is significantly worse.

It appears the image is not releasing its old images for some reason ... is there a workaround for this? Is this expected behavior? Is there a way to manually release the buffer? Thanks for any help!

Cheers