Solved

memory grow rapidly

Posted on 2007-03-27
9
399 Views
Last Modified: 2013-11-26
I use Visual Studio 2003 (VB.NET) to write a simple program.
In this program, the timer will call a funciton to check records of MSSQL via ADODB and activate Crystal Report 11 to print some document.

However, I found the memory usage for this program is growing rapidly. What seems to be problem ?

I have already close the ADODB.Recordset and set to nothing as well as nothing to CrystalDecisions.CrystalReports.Engine.ReportDocument before exit the funciton !

Cheers,
Andrew
0
Comment
Question by:andrewyu
9 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 18800476
(...my generic answer for this symptom...)

.Net is notorious for having simple apps consume huge amounts of memory...to the alarm of coders who have never seen this before.

The GC (Garbage Collector) works well but doesn't run as often as most people think it should.  In most cases, if the system as a whole needs memory, then the GC will clean up and reduce the footprint of your app.

A quick indication of whether you have an actual memory leak or not, is to see what happens when the app is CLOSED.  If the memory is all reclaimed then you do NOT have a leak and it's just the GC working in a way that you didn't expect.  If you close the app and the memory is not released back to the system then you have a problem.

I've also seen other posts where the cause of the leak was the use of third party controls.
0
 
LVL 21

Expert Comment

by:mastoo
ID: 18800494
0
 

Author Comment

by:andrewyu
ID: 18800766
Is there any way to FORCE the Garbage Collector to clean up the Garbage ?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 30 total points
ID: 18800824
See GC.Collect():
http://msdn2.microsoft.com/en-us/library/xe0c2357.aspx

But calling it too often can have a detrimental effect on your applications speeed!
0
 
LVL 21

Assisted Solution

by:mastoo
mastoo earned 30 total points
ID: 18800924
Here's a good microsoft link:

http://msdn.microsoft.com/msdnmag/issues/06/11/CLRInsideOut/default.aspx

with this relevant quote:

In general it is not recommended that you induce GC collections. In most cases, if # Induced GC indicates a high number, you should consider it a bug. Most of the time people induce GCs in hopes of cutting down the heap size, but this is almost never a good idea. Instead, you should find out why your heap is growing.
0
 
LVL 8

Expert Comment

by:doraiswamy
ID: 18806400
Perhaps you can modify your app so that you do not have to instantiate a new CrystalDecisions.CrystalReports.Engine.ReportDocument everytime you enter the timer event.

By the way, what prompted you to check the memory usage? Did you get any exception?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now