[Kde-bindings] Memleak in Korundum?

Richard Dale Richard_Dale at tipitina.demon.co.uk
Mon Aug 28 12:17:55 UTC 2006


On Monday 28 August 2006 12:47, Caleb Tennis wrote:
> I've been seeing some memory leaks in my Korundum programs lately,
> particularly those with heavy usage of dcop.  Below I've got a minimal
> example that exhibits the issue.  Basically, this program grows in size
> forever (after 3 days it gets to over 100MB of system memory).  In the
> latest Linux kernels (2.6.16+), the system seems to start randomly killing
> processes to counteract high levels of memory usage (I have 4+ of these
> scripts running on a machine).
>
> Is there an easy way to try and deduce where the memory is being eaten up?
>  I'm not doing anything facy with Ruby itself, so I'm doubtful it's a leak
> within Ruby, but you never know...
>
>
> require 'Korundum'
> @dcopclient = KDE::DCOPClient.new
> @dcopclient.attach
> @dcopclient.registerAs("update_fuel")
> @dcop = KDE::DCOPRef.new("gina", "MessageHandlerBase")
> @dcop.setDCOPClient(@dcopclient)
>
> @sp = File.open("/dev/tts/5", File::RDWR | File::NONBLOCK)
> @sp.flush
>
> while(true)
>
> @fbm = sprintf "%.3f", `dcop gina MessageHandlerBase GetChannelFinalValue
> fuel_bucket_m`.to_f
> @fr = sprintf "%.3f", `dcop gina MessageHandlerBase GetChannelFinalValue
> fuel_rate_c`.to_f
>
> #@estop = `dcop gina MessageHandlerBase GetControlChannelValue estop`
> #@meas = `dcop gina MessageHandlerBase GetControlChannelValue
> control_MEASURE`
>
> @estop = @dcop.call("GetControlChannelValue","estop").to_i
> @meas = @dcop.call("GetControlChannelValue","control_MEASURE").to_i
>
> @command = "fuel:#{@fbm},fuel_rate:#{@fr}"
> (@command << ",estop") if @estop.to_i > 5
> (@command << ",measure") if @meas.to_i > 5
>
> @sp.puts(@command);
>
> puts "Writing string: #{@command}"
>
> sleep 0.5
>
> begin
> gotdata = @sp.sysread(200)
> gotdata.split(",").each do |val|
>   if (val =~ /(.+):(.+)/)
>     @dcop.call("SetDataValue(QString,double)","#{$1}",$2.to_f)
>   end
> end
> puts "Got data #{gotdata}"
> rescue Errno::EAGAIN
> end
>
> sleep 0.5
>
> end
I been doing some memory leak investigation for Qt4 QtRuby on Mac OS X with 
MallocDebug, and managed to track down and fix some things. But the colliding 
mouse QGraphicsView example still gets steadily bigger, and I haven't been 
able to find out why yet. I can backport those fixes to the Qt3 version 
though and see if it makes any difference.

Without a tool like MallocDebug it's very hard to fix this sort of thing, and 
I don't know of anything similar for Linux - is there one of the valgrind 
related tools for doing this?

-- Richard



More information about the Kde-bindings mailing list