Memory Management Problem

R

RobbGMelenyk

I've got a Windows Service written in C# that is having some
unfortunate memory issues. I've been working with .NET MemProfiler and
AllocationProfiler. But you don't have to use those programs to notice
the memory leak. The memory usage in the TaskManager for the process
can be seen climbing and climbing, MBs at a time.

When using MemProfiler, I noticed the Win32 Heap is what seems to be
growing. I've been searching on the internet for Win32 Heap references
but I haven't found much. So what I'm asking is does anyone have some
links to explain on a .NET service interacts with this heap and why it
would get so large?

As a side note, MemProfilers is also reporting that my String instances
are the most troublesome. I'm using them like I would in a regular
application, nothing unordinary. Could some of my memory issues be
related to the timer_elasped event which might be hold reference to my
objects? I don't dispose the timer because, well, I kinda need it ;)

Thanks for any help.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What amounts are we talking about?

Your post is vague at best.

Are you creating lot of objets? are you keeping references to those objets
for long time?

You do not need to dispose the timer though. At the end that is only one
instance ;)
 
C

Chris Mullins

It should be easy enough to tell what's going on.

I use the SciTech .Net Memory Profiler (is that the same one you're using),
and when I have this type of issue, I just grab a heap snapshot, wait a few
minutes, and grab another heap snapshot.

I then look to see what's new, and from there I can usually track the leak
down pretty quickly.

As for the Win32 Heap growing, that's a bit misleading. As you clean up
issues in your Managed Heap, you'll see this stop. This threw me for a loop
a while back, as I was convinced I had a weird GDI problem that was causing
the Win32 heap to grow unboudned. Turned out to be a standard "keeping the
reference around" issue...
 

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