[Kde-bindings] Memleak in Korundum?
Caleb Tennis
caleb at aei-tech.com
Mon Aug 28 11:47:03 UTC 2006
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
More information about the Kde-bindings
mailing list