I am using Sql Server 2000 with no db specific features. I am not using
Spring for any database related objects. I do not have any shared objects in
the code that I have written. The Windows Service is using a set of class
libraries that I use in other places (web services, web application).
In a nutshell I use spring to inject "pipeline objects". I have a class
called a Pipeline which is nothing more than a container for one or more
objects which implement an ICommand interface. A Pipeline also implements
the ICommand interface so they can be contained inside of each other
although I don't currently have any pipeline set up to do that.
Just like pipelining commands in the Unix world, a command has an input and
produces an output. The output makes it way through the full pipeline until
you have the finished output. A command does not have to produce a new
output in which case it just passes along the input. While the Windows
Service is serially processing the objects and thus my pipelines are only
being used one at a time, the web service which make use of the same class
library can conceivably have multiple users accessing a pipeline at the same
time and thus the state of the input and output cannot be shared. (thus no
singleton)
I'm working in the mortgage industry and doing electronic recording of real
estate documents. An electronic recording is represented by Xml. The Windows
service looks for electronic recordings that have a status indicating
whether they are ready to be sent to or retrieved from a county in the U.S..
I use a pipeline to wire up the steps necessary to get the Xml into the
format needed by a county since it differs across counties. So, for example,
I'll start with our internal version of the xml and pass it into a county
specific pipeline. The pipeline might do something like: transform the xml
into the format required by the county, wrap the county xml in a digitial
signature, save a copy out to the network for debugging, validate the xml
and then send it via the county's remote web service.
With this in place, as new counties in the U.S. add electronic recording
capabilities, I can wire up new county pipelines with either minimal or no
rebuilding of applications.
Anyway, I'm not sure any of this is relevant to solving my problem but it's
always fun to talk about what you are working on with other developers. If I
tried to tell this to a non-programmer their eyes would just glaze over with
nothing more than a "Oh, so you do mortgage stuff." :)
The people who have suggested using WinDbg matches what I've found online
for tips in debugging memory problems. My problem is that I'm not really
sure how to read the memory dump once I have it. I'll just have to keep
trying to learn more.
On 9/7/07, Lear, Russell <[EMAIL PROTECTED]> wrote:
>
> Bob,
>
> 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 sense)?
>
> 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?
>
> Thanks,
> Russell.
>
> ------------------------------
> *From:* Bob Hanson [mailto:[EMAIL PROTECTED]
> *Sent:* Thursday, September 06, 2007 9:13 AM
> *To:* [email protected]
> *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 POCO.
>
> 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 <[EMAIL PROTECTED]> wrote:
> >
> > 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.
> >
> > Regards,
> > Dustin
> >
> >
> > >>> "Bob Hanson" <[EMAIL PROTECTED]> 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 minutes.
> >
> > 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.
> >
> > Thanks,
> > Bob
> >
>
>