473,387 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to release memory used by application

I write a Windows Application which uses db connections and some COM dll.
After running consecutively for 12 hours, the memory of the application
increased from 30MB to 130MB.

How can I trace the main cause of the memory used and how can I release
them?

Thanks!

Mullin
Nov 16 '05 #1
3 12986
Try to explicitly release COM objects through Marshal.ReleaseComObject().
Please note that ANY reference to an instance released through
Marshal.ReleaseComObject() becomes invalid, not only the reference passed as
the argument.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:um**************@tk2msftngp13.phx.gbl...
I write a Windows Application which uses db connections and some COM dll.
After running consecutively for 12 hours, the memory of the application
increased from 30MB to 130MB.

How can I trace the main cause of the memory used and how can I release
them?

Thanks!

Mullin


Nov 16 '05 #2
Hi Mullin
You can always use the GC.collect() method which forces the Garbage
collector to do a memory collection instantly . however, this is not the
best practice since the garbage collector (GC) should do collection on its
own at the best suited time according to its algorithm. There might be
something with your application that use memory in a way that is very
efficient ( for example you may be using string object instead of
stringBuilder for extensive string operations ) .
The best way to know what exactly is wrong with your program is to use the
CLR profiler . it is a tool that allow you to see how your program manage
memory ( see this link
http://msdn.microsoft.com/isapi/goms...details.aspx?F
amilyId=86CE6052-D7F4-4AEB-9B7A-94635BEEBDDA&displaylang=en )
Even if you are not a very expert user of CLR you will be at least able
to see what are the object that are in your memory ( and from these you can
know what code allocate these objects and what is wrong with it ). Try to
get the tool from the link and start using it to analize your program and
if you have any question on the tool please post it and I will be looking
back on this thread to see if I can help with anything
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3
Hi, Mulin

You can download CLR Profiler from MS site. It's a bit unstable but "free"
and can get you started. Usually such symptoms are related to "badly"
written code, which creates a lot of objects but doesn't help GC to free
unused memory. You might want to check also
http://msdn.microsoft.com/library/de...etperftips.asp

HTH
Alex

"Mullin Yu" <mu*******@ctil.com> wrote in message
news:um**************@tk2msftngp13.phx.gbl...
I write a Windows Application which uses db connections and some COM dll.
After running consecutively for 12 hours, the memory of the application
increased from 30MB to 130MB.

How can I trace the main cause of the memory used and how can I release
them?

Thanks!

Mullin

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marc | last post by:
I am using Visual Studio 2003 with .NET Framework 1.x on XP SP2. I am executing the following code (see also http://dturini.blogspot.com/2004/06/on-past-few-days-im-dealing-with-som e.html) ...
3
by: Paul Cameron | last post by:
Hello, We've recently migrated a very large (40+ projects, 1+ million LOC) VC6 workspace to VC7.1. In general, the compiler and linker are slower. The worst seems to be the release link; under...
1
by: spiff | last post by:
We are migrating from VC++ 6 to VC++ 2003. It is a plain, unmanaged application with both C and C++ source. When running the debug build, even outside the debugger, the memory allocation/deallocation...
10
by: babak | last post by:
Hi everybody I'm working with a project in embedded Visual Studio 4 and I have a general problem which I hope that somebody can help me with. My problem is the following: My project works fine in...
5
by: Rodrigue | last post by:
I have code where I populate a data table using visual basic.net code. I call the clear method on the table but it does not seem to release the memory. When I populate the table again, the memory...
2
by: Epetruk | last post by:
Hello, I have a problem where an application I am working on throws an OutOfMemoryException when I run it in Release mode, whereas it doesn't do this when I am running in Debug. The...
1
by: Amol J Kothawade | last post by:
Hi, I want to release memory consumed by database. I used datagridview in my windows form and provided dataset for database. after closing that application i find that it allocate the memory for...
4
by: John Sheppard | last post by:
Hello all, I have an application written in VB.Net that comsumes a webservice. We are having issues with speed. I have not ruled out a webservice problem, and this was my first guess. However...
3
by: touf | last post by:
HI, In my windows application (VB.NET) when I open a form the memory is increasing but When I close it the memory doen't decrease (task manager). each time I close the form and re-open it the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.