# Memory leak with WSDLDriverFactory?

**URL:** <https://www.ruby-forum.com/t/memory-leak-with-wsdldriverfactory/125115>\
**Category:** Rails\
**Created:** [January 5, 2008, 6:12pm UTC](https://www.ruby-forum.com/t/memory-leak-with-wsdldriverfactory/125115 "2008-01-05T18:12:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sp00nyg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sp00nyg](https://www.ruby-forum.com/u/sp00nyg)\
**Post date:** [January 5, 2008, 6:12pm UTC](https://www.ruby-forum.com/t/memory-leak-with-wsdldriverfactory/125115/1 "2008-01-05T18:12:40Z")

</div>

My app makes use of a 3rd party webservice to lookup company  
information. However, there seems to be a major memory leak with  
WSDLDriverFactory.

I do:  
class MyService  
@@auth\_hash = { :username =\> ‘username’, :password =\> ‘password’ }  
@@wsdl = ‘[http://mywsdlurl](http://mywsdlurl)’  
@@driver = SOAP::WSDLDriverFactory.new(@@wsdl).create\_rpc\_driver

# Call this several times

def self.search\_firms(name, state = ‘’)  
results = @@driver.Firms\_Info({ :name =\> name, :state =\>  
state}.merge(@@auth\_hash))

# Process the results

end  
end

Every call to driver.Firms\_Info grabs memory that I can never get  
back. My app will process hundreds (sometimes 1000’s) of companies at  
a time, but the process ends up sucking up all my memory and things  
slow to a crawl. No matter what I do I can’t get the memory back. I  
tried sprinkling GC.start calls around and make sure to set things to  
nil when done. In the end, I commented out everything but the  
driver.Firms\_Info call, and I still lost 100’s of megs very quickly.

I saw several mentions of a memory leak in Hash, but they are old. I  
know WSDLDriverFactory converts everything to Hash, so maybe that  
isn’t fixed yet.

Anyone else see this? Any work-arounds?

I’m using Ruby 1.8.6 and Rails 2.0.2.

---

<div class="post-metadata">

**Author:** ![sp00nyg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sp00nyg](https://www.ruby-forum.com/u/sp00nyg)\
**Post date:** [January 5, 2008, 10:01pm UTC](https://www.ruby-forum.com/t/memory-leak-with-wsdldriverfactory/125115/2 "2008-01-05T22:01:16Z")

</div>

After a little more digging, it looks like the leak happens whenever  
the SOAP server throws an exception. I handle the exceptions in the  
caller and continue on, but driver seems to hold onto all the memory  
of the results. Reloading the driver doesn’t help.

Unfortunately, the vendor’s SOAP server is prone to throwing errors,  
so I’m stuck. I guess I could implement the SOAP client raw, but I  
would think WSDLDriverFactory would ensure that its resources were let  
go even when there is an exception.

Thoughts?
