ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lear, Russell" <Russell.L...@xerox.com>
Subject RE: memory leak with windows service?
Date Fri, 07 Sep 2007 20:47:02 GMT
I'm in the process of setting up a service similar to what you describe
("similar" at the 30,000 ft. level of detail).  Just curious if you've
got an answer for this?  Is it a "feature" specific DB / DB driver set
you're using?  You mention that you have singleton="false" - is that for
all spring-managed objects or just for the main or root object(s)?  Are
there any shared objects like a hashtable or list or similar container?
Are you able to inspect objects produced & managed by spring to see if
any of them are accumulating crud (in a bad sense, not in the CRUD
If you run with singletons, do you still get this problem?  (this
probably breaks the correctness of the service, but it might still be
interesting, especially if you're able to do some level of setup after
Spring returns the objects).
I don't suppose you've been brave enough to trace what's happening in
the spring source?


	From: Bob Hanson [mailto:mnbob70@gmail.com] 
	Sent: Thursday, September 06, 2007 9:13 AM
	To: user-cs@ibatis.apache.org
	Subject: Re: memory leak with windows service?
	Re #1: Believe me, I've been doing this long enough to know that
anytime I want to blame something else, I know it's probably my error. I
found a post http://www.thescripts.com/forum/thread213771.html that
mentions a similar problem.
	Re #2: See previous. :)
	Re #3: I don't think I have this issue. iBatis is used to return
	I use spring with the singleton="false" attribute for many of my
objects. Not sure why that would make any difference but I'll mention it
just in case. 
	On 9/6/07, Dustin Aleksiuk <Dustin.Aleksiuk@huskyenergy.ca>

		Hi Bob,
		It's hard to say without looking at your code, but here
are some opinions of mine:
		1. The GC is extremely intelligent. A memory leak in
managed code will be because you still have a reference somewhere to
memory, which the GC can't touch. I believe that 99 times out of 100
you're making a mistake by forcing the GC to clean up. 
		2. I bet it's not iBatis, Log4net or spring. Many people
(including me) use these every day with no issues. 
		3. Make sure you have no static fields or similar things
that could be keeping a hold on memory.

		>>> "Bob Hanson" <mnbob70@gmail.com> 9/6/2007 9:26 AM
		I don't know if this is even the proper place for me to
ask these questions but I'm hoping others may have had a similar
experience and can provide some advice.
		I have a Windows Service that runs on a Windows 2000
server. It uses a system timer that triggers a process to run every 30
		The process is straight forward, performing 4 separate
queries with each returning a list of objects. Those objects are then
used to perform some functionality which involves accessing remote web
services. A majority of the time only 2 of the 4 queries returns any
data. iBatis.Net is used for all database interaction. Log4Net is used
for logging. Spring.Net is used during the object processing.
		The problem I am having is that over time the Windows
Service is not releasing memory and eventually the service will throw an
out of memory exception and crash. The process is 100% managed code. How
long it takes to run out of memory seems to vary but it generally takes
more than 24 hours if not longer. 
		I already modified the process to return a list of Ids
instead of a list of complete objects. A list of only 100 ids would be a
large list so I'm not dealing with a lot of data. I then query for a
full object on an individual basis using the object id. 
		I also call the garbage collector directly to try to
force memory release.
		At this point I don't know what to do as the problem
still remains. So I'm wondering if anyone has seen this kind of memory
problem before when using a Windows Service with .NET. Also does anyone
know if I should focus on iBatis, Spring or Log4Net as the possible
cause? I've read about using a .net profiler tool but I have to admit
that I have a hard time understanding how to profile code. 

View raw message