Solved

memory grow rapidly

Posted on 2007-03-27
9
402 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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