Windows service memory problem

G

Guest

We are having issues with our windows services using memory and never
releasing it. We have one service that has a file watcher which takes an xml
file, inserts some records into a database, and creates a bunch of PDFs with
Crystal Reports. Another service is a remote object which serves as our data
access component -- basically it just executes stored procedures and returns
datasets. If you watch the services in task manager, you can see the memory
usage increase as it goes through whatever process (which I would expect),
once the process is over though, the memory usage does not decrease.
Eventually, we will get an out of memory exception because the service has
reached its limit. We have dissected the code 20 different ways to Sunday
and cannot figure out what is wrong. Is the memory in a service controlled
differently that other objects? Thanks for any help.
 
G

Greg Young

Are you by chance using large byte arrays? (i.e. reading/writing to streams)

If so they will be "Large Objects" and managed differently than normal
objects.

This is a very common confusion with a memory leak.

Use a profiler and see what kind of memory you are using (Large Objects, and
the varying generations)

Cheers,

Greg
 
G

Guest

Thanks for your reply.

We're not using large byte arrays, but we are passing a dataset back which,
of course, is probably a "Large Object". If they are large objects, how do I
reclaim that memory if dispose and GC is not getting it back? My issue isn't
that it is using memory but that it won't give it up when its done.
 
G

Greg Young

The dataset is probably not the problem, it is actually an aggregation of
many small objects.

Have you profiled your application?

Cheers,

Greg
 
G

Guest

Ok, here's where I start having trouble. When you say profiled are you
referring to all of the counters available with the performance monitor? If
so, which counters would be relevant? I can see the service has the heap
size for Gen 0, 1, 2, and large objects ever increasing but not sure what to
do with that? Thanks again for any help.
 
G

Greg Young

If large objects is increasing that is your problem ...

Your remote component ... is it a webservice? remoting?

Cheers,

Greg
 
G

Guest

Actually, I am pretty sure we solved it. I was so busy focusing on the class
that the remoting service exposed that I didn't pay attention to the service
itself. I was reading a post somewhere about a memory running amok if you
used RemotingConfiguration.Configure("Client.exe.config") in the service, we
don't do that, but I thought maybe global variables would do the same. So I
checked and the code was written with the port numbers being held in global
variables (not sure why but whatever), so I cleaned those up made them local
to a procedure and removed some code from the constructor for the service and
viola, it seems to be working. We haven't put it in produciton yet, but when
we tax it in Dev and Beta all is well. Thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top