473,769 Members | 5,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do I need to use GC.Collect? If yes, where?

Hello, here is what I am doing.

1) user accesses web page and clicks button to build report
2) web page accesses web service whose data type is DataSet
(public DataSet methodname()... )
3) web service connects to SqlServer, runs BIG report
4) data is returned to web service, web service returns DataSet to web
front-end
5) web front-end prompts user to save Excel file which contains the
DataSet data

While #3 is running, the aspnet_ws.exe process on the web server grows
big, like 200-500 MB.

The problem is the server doesn't seem to release that memory after the
report is done. A few more report runs and the server starts giving
memory errors.

I have seen people saying use GC.Collect() but where would I put that?

Nov 19 '05 #1
15 2247
Antonio,

No, you shouldn't be calling GC.Collect, ^especially^ in an ASP.NET
environment. ASP.NET gets into a nice little groove (in terms of GC's, and
when the pattern of use is consistent) which you don't want to mess with by
running your own GC's.

The errors that you are probably getting are due to the % of memory
ASP.NET is allowed to use before the process is recycled. You would have to
up this value in the web.config file for your application, to let your
ASP.NET process take up more memory.

If your report is returning data that is between 200-500 MB, then you
really need to reconsider the design of the report.

Also, Task Manager is not really suitable for monitoring the memory
consumption of an application. You should be using the performance counters
to determine what is being consumed/released, etc, etc.

In the end, ^don't^ call GC.Collect, as in this case, it isn't going to
do anything for you. Just make sure you dispose of all types that implement
IDisposable, and if your report is really that big, then raise the value of
the allowed memory consumption in the web.config file.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello, here is what I am doing.

1) user accesses web page and clicks button to build report
2) web page accesses web service whose data type is DataSet
(public DataSet methodname()... )
3) web service connects to SqlServer, runs BIG report
4) data is returned to web service, web service returns DataSet to web
front-end
5) web front-end prompts user to save Excel file which contains the
DataSet data

While #3 is running, the aspnet_ws.exe process on the web server grows
big, like 200-500 MB.

The problem is the server doesn't seem to release that memory after the
report is done. A few more report runs and the server starts giving
memory errors.

I have seen people saying use GC.Collect() but where would I put that?

Nov 19 '05 #2
"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello, here is what I am doing.

1) user accesses web page and clicks button to build report
2) web page accesses web service whose data type is DataSet
(public DataSet methodname()... )
3) web service connects to SqlServer, runs BIG report
4) data is returned to web service, web service returns DataSet to web
front-end
5) web front-end prompts user to save Excel file which contains the
DataSet data

While #3 is running, the aspnet_ws.exe process on the web server grows
big, like 200-500 MB.

The problem is the server doesn't seem to release that memory after the
report is done. A few more report runs and the server starts giving
memory errors.

I have seen people saying use GC.Collect() but where would I put that?


You would probably add a GC.Collect after you call Dispose on the object.
However, I wonder if that is the problem? Is your 200-500 MB data a group
of unmanaged Excel objects? If so, are you sure you're releasing ALL of the
objects?

Carl
Nov 19 '05 #3
ok so don't call GC.Collect(). I have added .Dispose to the datagrids
and datasets. The actual excel file downloaded is usually between 5
and 25 MB. I am not really sure why the process grows by 200 or more
MB. What performance counters would you suggest I watch in perfmon?

thank you Nicholas

Nov 19 '05 #4
ok so don't call GC.Collect(). I have added .Dispose to the datagrids
and datasets. The actual excel file downloaded is usually between 5
and 25 MB. I am not really sure why the process grows by 200 or more
MB. What performance counters would you suggest I watch in perfmon?

thank you Nicholas

Nov 19 '05 #5
The question is not how big is the excel file, the question is how big is
the dataset.
And what datagrids are you talking about? This is a webservice, what are the
datagrids used for?

Willy.

"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
ok so don't call GC.Collect(). I have added .Dispose to the datagrids
and datasets. The actual excel file downloaded is usually between 5
and 25 MB. I am not really sure why the process grows by 200 or more
MB. What performance counters would you suggest I watch in perfmon?

thank you Nicholas

Nov 19 '05 #6
Antonio,

It depends on what you want to see. If you run perfmon (from the run
dialog box), you will see a gazillion (ok, almost) entries for performance
counters. You can see things such as number of collections, memory
allocated, etc, etc. They are pretty self-describing, and can give you a
plethora of information.

Also, when working with the Excel sheet, you should make sure that you
call the static ReleaseComObjec t on the Marshal class to correctly release
the COM objects produced by it (it can leave references lying around).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
ok so don't call GC.Collect(). I have added .Dispose to the datagrids
and datasets. The actual excel file downloaded is usually between 5
and 25 MB. I am not really sure why the process grows by 200 or more
MB. What performance counters would you suggest I watch in perfmon?

thank you Nicholas

Nov 19 '05 #7
The question is not how big is the excel file, the question is how big is
the dataset.
And what datagrids are you talking about? This is a webservice, what are the
datagrids used for?

Willy.

"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
ok so don't call GC.Collect(). I have added .Dispose to the datagrids
and datasets. The actual excel file downloaded is usually between 5
and 25 MB. I am not really sure why the process grows by 200 or more
MB. What performance counters would you suggest I watch in perfmon?

thank you Nicholas

Nov 19 '05 #8
Antonio,

It depends on what you want to see. If you run perfmon (from the run
dialog box), you will see a gazillion (ok, almost) entries for performance
counters. You can see things such as number of collections, memory
allocated, etc, etc. They are pretty self-describing, and can give you a
plethora of information.

Also, when working with the Excel sheet, you should make sure that you
call the static ReleaseComObjec t on the Marshal class to correctly release
the COM objects produced by it (it can leave references lying around).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
ok so don't call GC.Collect(). I have added .Dispose to the datagrids
and datasets. The actual excel file downloaded is usually between 5
and 25 MB. I am not really sure why the process grows by 200 or more
MB. What performance counters would you suggest I watch in perfmon?

thank you Nicholas

Nov 19 '05 #9
The datagrid is to get the excel output. See below. I found this in
the asp.net ng. I call the web service which returns the dataset, then
I pass the dataset into this static method (I made it a static method
so all of my web pages can call it.

public static void ExportExcel(Sys tem.Data.DataSe t ds, int TableIndex,
string FileNameNoExten sion, System.Web.Http Response response) {
response.Clear( );
response.Charse t = "";
response.Conten tType = "applicatio n/vnd.ms-excel";
response.AddHea der("content-disposition", "attachment;fil ename=" +
FileNameNoExten sion + ".xls");
System.IO.Strin gWriter stringWrite = new System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter htmlWrite = new
System.Web.UI.H tmlTextWriter(s tringWrite);
System.Web.UI.W ebControls.Data Grid dg = new
System.Web.UI.W ebControls.Data Grid();
dg.DataSource = ds.Tables[TableIndex];
dg.DataBind();
dg.RenderContro l(htmlWrite);
response.Write( stringWrite.ToS tring());
response.End();
ds.Dispose();
}

Nov 19 '05 #10

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

Similar topics

1
10645
by: Paul Rowe | last post by:
Hi "You" I have two collection types declared at the SQL level. 1. Do you know of any known bugs with the BULK COLLECT clause used with the TABLE operator? I have a situation now where I am using a BULK COLLECT clause with a SELECT statement and a TABLE() operator in a join. I am finding that this select statement either returns the wrong result or the right result. The wrong result is always the same... too many rows where the...
0
1507
by: nick_faye | last post by:
Hi, I hope somebody can help me. I am collecting data from different external ms access database on my VB programming. I am using the SQL command as shown below: While strPaths(iCtr) <> "" And iCtr <= MAX_ALLOW_DBASE dbase.Execute "INSERT INTO DailySalesReport " & _ "SELECT table1.storeqs, table1.styleqs, table1.dateqs, table1.idnumberqs, table1.cashqs, table1.salesclerkqs, table1.qs,
5
1954
by: Richard | last post by:
Hi, I'm writing an MS Outlook 2000 Addin in C#. I have created C# classes that monitor folder events and do other business logic. Things work fine until I want to exit Outlook. When I exit Outlook I have to force 2 garbage collection cycles in order for all of my folder monitor classes to get cleaned up {else Outlook will not unload from memory}. In other words my OnDisconnect() method looks something like this:
2
1672
by: Eric Cadwell | last post by:
Does anyone know of any case in which the CLR explicitly calls GC.Collect? I have a form that when unloaded, shows # of induced GC's incremented by 5. This is killing performance. I have a feeling that it's related to calling Dispose on a particular control class like DataGrid, ListView, etc. TIA, Eric
9
8557
by: Frank Rizzo | last post by:
I understand the basic premise: when the object is out of scope or has been set to null (given that there are no funky finalizers), executing GC.Collect will clean up your resources. So I have a basic test. I read a bunch of data into a dataset by using a command and a data adapter object, .Dispose(ing) as I go. The moment the data is in the Dataset, the Mem Usage column in the Task Manager goes up by 50 MB (which is about right). I...
11
2026
by: Antonio | last post by:
Hello, here is what I am doing. 1) user accesses web page and clicks button to build report 2) web page accesses web service whose data type is DataSet (public DataSet methodname()...) 3) web service connects to SqlServer, runs BIG report 4) data is returned to web service, web service returns DataSet to web front-end 5) web front-end prompts user to save Excel file which contains the DataSet data
21
3375
by: Thelma Lubkin | last post by:
I would like my DLookup criteria to say this: Trim(fieldX) = strVar: myVar = _ DLookup("someField", "someTable", "Trim(fieldX) = '" & strVar & '") I don't believe that this will work, and I won't be at a machine with access to Access for a while, so can someone please tell me how to write this? thanks, --thelma
0
2023
by: redmondtab | last post by:
I have done this . Write a C program that will accept keyboard input and display a loan amortization schedule back on the screen. The program should ask for the Loan Amount (real number), Term of the Loan in months (integer), and the Interest Rate (real number); the input data should be validity checked. The output should list a heading showing the input values, then a separate line indicating Payment Number, Loan Balance, Payment...
4
1979
by: svgeorge | last post by:
I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) -------------------------------------------------------------------------------- How TO COLLECT THE ROWS CHECKED IN CHECK BOX IN THE DATASELECTED TO ANOTHER GRID VIEW ON CLICLING BUTTON I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) SIMILLAR TO HOTMAIL MODEL.....CHECK THE MAILS AND BRING THE CHECKED DATA TO ANOTHER PAGE
3
3643
by: oravm | last post by:
Hi, I re-write a query and used bulk collect to improve the performance of the batch process. The query below has NO compile error but when execute query there is error 'ORA-01403: no data found.' CREATE OR REPLACE PROCEDURE PROCESS_ANGKASA(REF_NO varchar2)is v_cntr_code varchar2(16); v_receipt_code varchar2(3); start_time number; end_time number;
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.