Loosing memory

  • Thread starter Thread starter Marius Horak
  • Start date Start date
M

Marius Horak

Hi,

I have a window program (C#) with 2 buttons, 2 labels and timer running
under Win2K (DotNet 1.1).
On Tick (every 30 mins) it will execute a procedure that reads a number of
files and add records to a database.
Before it finishes SqlDataReader and Connection I are being closed.
There are no global varaibles. All is inside that procedure. The Tick method
has 3 commands - disable timer, execute procedure, enable timer. When
started, the TaskManagers shows that the program uses about 6MB. Each time
the procedure is executed it adds 1.2MB.
Why? I was under impression that all memory used inside procedure is
released after it finishes.

Thanks

MH
 
taskmgr memory display is the memory that the clr allocates based on what it
thinks it is going to need. the more you run something in a given process,
the more mem the clr thinks that process is going to ultimately need. this
taskmgr memory will grow (and that really isn't too much to worry about
unless it never does down)... eventually the gc should run and clean some
things up...freeing up ram.

now on your connections.. are you disposing or just closing? ALWAYS dispose
if you are done with the connection.
 
Thank you.
I had connection close only. But after 2 days of running the I would expect
GC to clean it up.

MH
 
Hi Marius

The GC only cleans up managed resources (objects allocated on the heap). Things like database connections, file handles, etc are considered unmanaged, and the GC
doesn't touch them. Patrick is absolutely right; always run the dispose method (if one exists) when you're done with an object. That will take care of any unmanaged resources,
and the GC will do the rest.

-Chris

--------------------
From: "Marius Horak" <[email protected]>
References: <[email protected]> <#[email protected]>
Subject: Re: Loosing memory
Date: Mon, 16 Feb 2004 12:09:37 -0000
Lines: 7
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: 213.52.140.99
Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.general:124747
X-Tomcat-NG: microsoft.public.dotnet.general

Thank you.
I had connection close only. But after 2 days of running the I would expect
GC to clean it up.

MH


--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
 
Back
Top