473,785 Members | 2,449 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
15 2248
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 #11
Are you releasing your Excel references with Marshal.Release COMObject,
or just setting them to null?

http://support.microsoft.com/default...;EN-US;Q317109

Please note that this is one of the cases where MS actually does
reference manually calling GC.Collect ... although it's sort of a hack
to deal with reference counting problems in the RCW.

Antonio wrote:
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 #12

"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
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();
}


Ok, if I understand you correctly, you have following logical tiers:

1. browser client
2. a web application (asp.net)
3. a web service
4. a SQL DB

How about the physical tiers, do 2 and 3 run on the same server (not really
a server, if I'm not mistaken you run this on XP)?
Who's producing the Excel output? And what's the relation between this and
the DS generated by the report?

How large is the dataset passed from the WS to the WA, this is important as
if both run in the same process (aspnet_wp.exe) the working set will contain
two instances of the same DS at some point in time.
Willy.

Nov 19 '05 #13
Yes!

The server are Windows Server 2000 SP4. 2 and 3 DO run on the same
server! #2 is producing the excel file. #3 only connects to the
database and returns to #2 the dataset. then the dataset is handed to
the static method that productces the excel file.

I do not know how big the dataset is but I will try to look.

Nov 19 '05 #14

"Antonio" <bl*****@yahoo. com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
Yes!

The server are Windows Server 2000 SP4. 2 and 3 DO run on the same
server! #2 is producing the excel file. #3 only connects to the
database and returns to #2 the dataset. then the dataset is handed to
the static method that productces the excel file.

I do not know how big the dataset is but I will try to look.


Does 2 produce the Excel file through Office automation (COM)? If the answer
is yes, then all I can say is change you design and don't run Office
automation on the server from web applications. Office is not designed to be
used in such scenarios, "it doesn't scale" is an often heard issue but it's
not the worse.
Check following KB article as to why it is like this:
http://support.microsoft.com/default...b;en-us;257757

Willy.

Nov 19 '05 #15
Yes thank you that is a great answer. This is not using COM or any
office interop though. Please see the code in my earlier post.

Maybe I can try to pass to the static method the dataset by ref as to
not copy it in memory. Does that make a good suggestion?

Nov 19 '05 #16

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
1955
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
8558
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
3377
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
9645
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
9480
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,...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
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
6739
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
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
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
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.