Re: memory leak using system.windows.forms.timer
- From: Gestalt <sspenning@xxxxxxxxx>
- Date: Fri, 13 Feb 2009 13:03:14 -0800 (PST)
On Feb 11, 3:37 pm, Tom Shelton <tom_shel...@xxxxxxxxxxxxxxxxxx>
wrote:
On 2009-02-11, Gestalt <sspenn...@xxxxxxxxx> wrote:
On Feb 11, 1:43 pm, Tom Shelton <tom_shel...@xxxxxxxxxxxxxxxxxx>
wrote:
On 2009-02-11, Gestalt <sspenn...@xxxxxxxxx> wrote:
I'm working on a small application using the
system.windows.forms.timer. The intent is to set an interval and on
the tick event fire a function that returns the number of workstation
objects that reside in a specific OU in Active Directory.
On the surface the application runs great. Under the surface, it's a
different story. I've found that every time the tick calls a trivial
subroutine, memory leaks. I've tried summoning garbage collection
periodically but that has not resulted in any improvement in memory
consumption. Left overnight the app will bloat to over half a gig of
RAM consumed (and continuing to climb). I have tested it on XP Pro,
Vista SP1 (x64) and Windows Server 2008 (x86).
The subroutine that appears to be leaking is here as follows:
Private Sub CheckComputers()
Dim intCount As Integer
intCount = CountADComputers(My.Settings.strTargetDN)
If intCount > My.Settings.intTargetCount Then
intTrigger = 1
Else
intTrigger = 0
End If
intCount = Nothing
End Sub
I have found that if I substitute the call to the CountADComputers
subroutine with a static number (e.g. 1) I still leak memory. If I
leave this subroutine out of the program then the leak stops (and
obviously the program does nothing).
Can anyone think of a reason why this would be causing a problem?
Repost the question to the vb.net group:
microsoft.public.dotnet.langauges.vb
And when you do - post the code to your CounADComputers method. This is
obviously where the issue most likely is. You are keeping a reference to
something around that you shouldn't be.
--
Tom Shelton
Thanks for the advice, I'll repost in the other forum.
And for the record, I indicated that the problem occurs even if I
remove the reverence to the CountADComputers subroutine and replace it
with a static integer. I believe that would make it less likely to be
the "obvious" source of the issue.
Ah.. sorry... i misread that :)
--
Tom Shelton
It is I who should be sorry. You were indeed correct about the source
of the memory leak. I later discovered that my Visual Studio install
was not consistently generating new builds on demand so when I thought
I was testing the app with the subroutine commented out, it was in
fact still very much active.
Using Ants Profiler I have discovered that the AD search is actually
accumulating all of its results in memory and never releasing them.
Right now researching Application Domains as it has been suggested
that by putting my leaky process into a separate application domain I
can then dismiss it when done and the system should then be forced to
clear the unwanted data from memory.
I apologize for my snappish response earlier.
.
- References:
- memory leak using system.windows.forms.timer
- From: Gestalt
- Re: memory leak using system.windows.forms.timer
- From: Tom Shelton
- Re: memory leak using system.windows.forms.timer
- From: Gestalt
- Re: memory leak using system.windows.forms.timer
- From: Tom Shelton
- memory leak using system.windows.forms.timer
- Prev by Date: Get rid of references
- Next by Date: Auto formatting chart labels to look stacked- Microsoft 2000
- Previous by thread: Re: memory leak using system.windows.forms.timer
- Next by thread: translate menu in resource file
- Index(es):
Relevant Pages
|