From: David Ross Date: 2004-10-29T11:13:10+09:00 Subject: Re: [BUG] Memory leak in ruby_1_8 Charles Comstock wrote: >would that be because the entire ruby file is client.rb and everytime >you run that it creates a server and doesn't quit after backgrounding >it and creating a sighandler? It would be helpful if you labeled what >each filename is for an example like this. > Charles Comstock > > >On Fri, 29 Oct 2004 10:24:15 +0900, David Ross wrote: > > >>Hello, >> >>I have a small memory leak. I tried using cvs to get ruby_1_8 right now. >>Okay, there is no leak with 1.8.2 preview. Its in stable. I tried >>running the attached scripts and ran test.sh just to make sure like I >>always do and it started to leak. Please try searching for the leak >>while I do as well.. >> >>David Ross >>-- >>Hazzle free packages for Ruby? >>RPA is available from http://www.rubyarchive.org/ >> >> >>#!/usr/bin/env ruby >> >>require 'soap/rpc/standaloneServer' >> >>class SqlCustomerPortServer < SOAP::RPC::StandaloneServer >> class SqlCustomerService >> def self.create >> new >> end >> >> def deposit(amt) >> "deposit #{amt} OK" >> end >> >> def withdrawal(amt) >> "withdrawal #{amt} OK" >> end >> >> end >> >> Name = 'http://tempuri.org/sqlCustomerPort' >> def initialize(*arg) >> super >> add_rpc_servant(SqlCustomerService.new, Name) >> end >> >>end >> >>if $0 == __FILE__ >> svr = SqlCustomerPortServer.new('SqlCustomerPortServer', nil, '0.0.0.0', 7000) >> trap(:INT) do >> svr.shutdown >> end >> status = svr.start >>end >> >> >>require 'soap/rpc/driver' >>require 'soap/header/simplehandler' >> >>server = ARGV.shift || 'http://localhost:7000/' >> >>ns = 'http://tempuri.org/sqlCustomerPort' >>serv = SOAP::RPC::Driver.new(server, ns) >>serv.add_method('deposit', 'amt') >>serv.add_method('withdrawal', 'amt') >> >>#serv.wiredump_dev = STDOUT >> >>p serv.deposit(150) >>p serv.withdrawal(120) >> >> >>#!/bin/sh >>while [ true ] >>do >> ruby client.rb >>done >> >> >> >> >> > > > > *sigh* Sorry, mozilla mail fails me again. test.sh ---------------------[start] #!/bin/sh while [ true ] do ruby client.rb done ---------------------[stop] server.rb ---------------------[start] #!/usr/bin/env ruby require 'soap/rpc/standaloneServer' class SqlCustomerPortServer < SOAP::RPC::StandaloneServer class SqlCustomerService def self.create new end def deposit(amt) "deposit #{amt} OK" end def withdrawal(amt) "withdrawal #{amt} OK" end end Name = 'http://tempuri.org/sqlCustomerPort' def initialize(*arg) super add_rpc_servant(SqlCustomerService.new, Name) end end if $0 == __FILE__ svr = SqlCustomerPortServer.new('SqlCustomerPortServer', nil, '0.0.0.0', 7000) trap(:INT) do svr.shutdown end status = svr.start end ---------------------[stop] client.rb ---------------------[start] require 'soap/rpc/driver' require 'soap/header/simplehandler' server = ARGV.shift || 'http://localhost:7000/' ns = 'http://tempuri.org/sqlCustomerPort' serv = SOAP::RPC::Driver.new(server, ns) serv.add_method('deposit', 'amt') serv.add_method('withdrawal', 'amt') #serv.wiredump_dev = STDOUT p serv.deposit(150) p serv.withdrawal(120) ---------------------[stop] The server and client both work perfectly without memory leaks in 1.8.2 preview and before. They do not work with stable-snapshot nor the latest ruby_1_8 from cvs I just ran 30 minutes ago. The server starts leaking when you keep making the client connect over and over. So about after 800 connections the memory would be exhausted. These are ready to test scripts, I tool them from NaHi's samples instead of using mine. These scripts work fine on 1.8.2 preview. David Ross -- Hazzle free packages for Ruby? RPA is available from http://www.rubyarchive.org/