473,750 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Out-of-memory error: sample app

I'm seeing some unexpected behavior in Framework 2.0 / IIS 5.1 in high
memory usage situations. The first problem I had is that the default
machine.config for Framework 2.0 does not include a memoryLimit entry -
Framework 1.0 was set to 60% by default. But even after adding a
memoryLimit = 60 to my processModel section all available memory still
gets used up and the process dies - the same app under Framework 1.1
returns the requested rows - no matter how many I request.

The other problem I've seen is that after the 2.0 thread dies or is
killed if I return to that page - without clicking the button to
request datarows - memory begins to skyrocket again immediately. It
seems like ASP.NET is somehow remembering what it was doing when it
died and wants to pick up and do it again - which of course leads to
another crash.

Note: I know it's poor practice to load so much data into a grid. I'm
dealing with a huge production legacy application here and we are in
the process of refactoring. In order to take advantage of some third
party tools we upgraded to framework 2.0. At this point we started
having memory problems with some admittedly poorly designed pages that
allow users to pull ridiculous amounts of data. So if your only answer
is "don't pull so much data" well . . . thanks, no kidding.

Here's my sample app - basically it creates a huge datatable and tries
to load it into a grid:

BigTable.aspx:

<%@ Page language="c#" Codebehind="Big Table.aspx.cs"
AutoEventWireup ="false" Inherits="BigTa ble.BigTable" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>BigTable </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="grdRows" style="Z-INDEX: 101; LEFT: 1px; POSITION:
absolute; TOP: 1px" runat="server"
Width="792px"></asp:DataGrid>
&nbsp;
<asp:Label id="lblRowsToLo ad" style="Z-INDEX: 104; LEFT: 8px;
POSITION: absolute; TOP: 152px"
runat="server" Width="144px">R ows To Load</asp:Label>
<asp:TextBox id="txtRowsToLo ad" style="Z-INDEX: 103; LEFT: 8px;
POSITION: absolute; TOP: 176px"
runat="server" Width="80px">5</asp:TextBox>
<asp:Button id="btnLoadRows " style="Z-INDEX: 102; LEFT: 8px;
POSITION: absolute; TOP: 200px"
runat="server" Text="Load Rows"
OnClick="btnLoa dRows_Click"></asp:Button>
&nbsp;
</form>
</body>
</HTML>


BigTable.aspx.c s:
using System;
using System.Data;

namespace BigTable
{
public partial class BigTable : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid grdRows;
protected System.Web.UI.W ebControls.Butt on btnLoadRows;
protected System.Web.UI.W ebControls.Text Box txtRowsToLoad;
protected System.Web.UI.W ebControls.Labe l lblRowsToLoad;

protected void btnLoadRows_Cli ck(object sender,
System.EventArg s e)
{
System.Data.Dat aTable dt = new DataTable();
for (int x = 0; x < 10; x++) //10 columns
{
dt.Columns.Add( x.ToString(), typeof(String)) ;
}
System.Data.Dat aRow dr;
int yTotal = int.Parse(txtRo wsToLoad.Text);
for (int y = 0; y < yTotal; y++) //Add the requested number
of rows.
{
dr = dt.NewRow();
for (int x = 0; x < 10; x++) //insert a string value
into each column of each row.
{
dr[x] = x.ToString();
}
dt.Rows.Add(dr) ;
}
grdRows.DataSou rce = dt;
grdRows.DataBin d();
}
}
}

BigTable.aspx.d esigner.cs:

//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.507 27.42
//
// Changes to this file may cause incorrect behavior and will be
lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace BigTable {

public partial class BigTable {
protected System.Web.UI.H tmlControls.Htm lForm Form1;
}
}

Sep 19 '06 #1
3 1859
See responses inline:
The other problem I've seen is that after the 2.0 thread dies or is
killed if I return to that page - without clicking the button to
request datarows - memory begins to skyrocket again immediately. It
seems like ASP.NET is somehow remembering what it was doing when it
died and wants to pick up and do it again - which of course leads to
another crash.
Sounds like it's taking the ViewState of the textbox and re-submitting
which is of course, going to ask for the same data again, and thus,
crash your app again.

Does this happen when you CLOSE the web browser and re-open?
Note: I know it's poor practice to load so much data into a grid.
Yes, Indeed it is. There is no way you can limit the amount of data to
be populated?

How much data are we actually talking about here? 50 rows? 500 rows?
5000 rows? 500,000 rows?

I'm
dealing with a huge production legacy application here and we are in
the process of refactoring. In order to take advantage of some third
party tools we upgraded to framework 2.0. At this point we started
having memory problems with some admittedly poorly designed pages that
allow users to pull ridiculous amounts of data. So if your only answer
is "don't pull so much data" well . . . thanks, no kidding.
Don't pull so much data. =)
Here's my sample app - basically it creates a huge datatable and tries
to load it into a grid:

BigTable.aspx:

<%@ Page language="c#" Codebehind="Big Table.aspx.cs"
AutoEventWireup ="false" Inherits="BigTa ble.BigTable" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>BigTable </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="grdRows" style="Z-INDEX: 101; LEFT: 1px; POSITION:
absolute; TOP: 1px" runat="server"
Width="792px"></asp:DataGrid>
&nbsp;
<asp:Label id="lblRowsToLo ad" style="Z-INDEX: 104; LEFT: 8px;
POSITION: absolute; TOP: 152px"
runat="server" Width="144px">R ows To Load</asp:Label>
<asp:TextBox id="txtRowsToLo ad" style="Z-INDEX: 103; LEFT: 8px;
POSITION: absolute; TOP: 176px"
runat="server" Width="80px">5</asp:TextBox>
<asp:Button id="btnLoadRows " style="Z-INDEX: 102; LEFT: 8px;
POSITION: absolute; TOP: 200px"
runat="server" Text="Load Rows"
OnClick="btnLoa dRows_Click"></asp:Button>
&nbsp;
</form>
</body>
</HTML>


BigTable.aspx.c s:
using System;
using System.Data;

namespace BigTable
{
public partial class BigTable : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid grdRows;
protected System.Web.UI.W ebControls.Butt on btnLoadRows;
protected System.Web.UI.W ebControls.Text Box txtRowsToLoad;
protected System.Web.UI.W ebControls.Labe l lblRowsToLoad;

protected void btnLoadRows_Cli ck(object sender,
System.EventArg s e)
{
System.Data.Dat aTable dt = new DataTable();
for (int x = 0; x < 10; x++) //10 columns
{
dt.Columns.Add( x.ToString(), typeof(String)) ;
}
System.Data.Dat aRow dr;
int yTotal = int.Parse(txtRo wsToLoad.Text);
for (int y = 0; y < yTotal; y++) //Add the requested number
of rows.
{
dr = dt.NewRow();
for (int x = 0; x < 10; x++) //insert a string value
into each column of each row.
{
dr[x] = x.ToString();
}
dt.Rows.Add(dr) ;
}
grdRows.DataSou rce = dt;
grdRows.DataBin d();
}
}
}
Can we see any "actual" code? This seems to just be an example of
building a DataTable.

BTW, your Web frontend really "shouldn't" be creating your data model
on the fly. Simply from a maintainability stand-point. I always defer
these tasks to another tier/assembly. Too much messiness in the UI =)

Hope this might help!

Sean

Sep 19 '06 #2
Can we see any "actual" code? This seems to just be an example of
building a DataTable.
The idea is to compile and run this same little app under 1.1 and 2.0
and observe the differences when requesting something outrageous like
500,000 rows. Under 1.1 if you stick around long enough you'll
eventually get the rows - and even better it tends to keep the CPU
running at about 50% so that other sessions aren't completely choked.
Under 2.0 memory seems to zoom up and down, the CPU remains red-lined
for long periods of time, and eventually the process crashes.

Sep 19 '06 #3
well,

IMO, there is a couple of things here that is not complete.

1.) you mentioned your running this in IIS 5.1, how does this perform
when you test it under IIS 6.0? same results?

2.) Have you ran a profiler or tested this against an ACT project?
perhaps then you can pinpoint exactly where the problem lay, if it is
in memory allocation, CPU reads, etc...

3.) What type of machine are you running this on? How much memory in
the box? RAID drives? What server version? 2000 or 2003? or is it just
XP?

There has been a number of times that when I run something on my dev
machine, it is slow as molasses, but as soon as I plop it on a 2003
server running IIS 6 with 2 gigs of ram, dual cpu's and a beefy RAID
array, that slowness is negligable for what I am doing in code.

I guess my final point here is, when all you have is a hammer,
everything looks like a nail =)

Can you provide some of the details above?

Thanks

Sean

George1776 wrote:
Can we see any "actual" code? This seems to just be an example of
building a DataTable.

The idea is to compile and run this same little app under 1.1 and 2.0
and observe the differences when requesting something outrageous like
500,000 rows. Under 1.1 if you stick around long enough you'll
eventually get the rows - and even better it tends to keep the CPU
running at about 50% so that other sessions aren't completely choked.
Under 2.0 memory seems to zoom up and down, the CPU remains red-lined
for long periods of time, and eventually the process crashes.
Sep 19 '06 #4

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

Similar topics

4
8636
by: FilexBB | last post by:
Hi Folks, I have tried to redirect system.out for a while and then set it back, but it can't set it back as following program snapshot ByteArrayOutputStream baos = new ByteArrayOutputStream(); System.setOut(new PrintStream(baos, true)); System.out.println("hello"); System.err.println(baos); System.setOut(System.out);
4
36751
by: Merlin | last post by:
Hi there, I would like to check if a string is a valid zip code via Javascript. Length and existents are already checked. How can I find out if the string contains characters other than numbers? Example: 834F7 schould be false since it countains an F character
5
8384
by: Mike Carroll | last post by:
I have a COM server that's generally working ok. But one of its methods, when the IDL gets read by the Intertop layer, has parameters of type "out object". The C# compiler tells me that it can't convert from object to out object, or from int* to out object, or from object to out object. In fact, I can't find anything at all that it will accept as a parameter on the call. I don't think this is a COM issue, because if I wrote my own C#...
2
2331
by: Chua Wen Ching | last post by:
Hi there, I am wondering the difference between attribute and out keywords. Are they the same or does it serve any different purposes? I saw the and out usage in this code, and i had idea, does it had differences. internal static extern Boolean ReadFile(IntPtr hFile, Byte lpBuffer,
9
1715
by: Michi Henning | last post by:
Hi, I'm generating both VB and C# code from language-independent interface definitions, which is why I'm raising this issue. (The problem apppears to be somewhat esoteric, but it is real in my situation and is about more than just convenience.) C# has the notion of an out parameter (which is different from pass by value and pass by reference), but VB only understands pass by value and pass by reference. This means that parameters that
4
2369
by: Jon | last post by:
Why are out parmeters included in an BeginInvoke? They seem to do nothing? TestProgam: using System; namespace TempConsole { class App { public delegate void MyDelegate( out byte b, out string s );
14
7350
by: stic | last post by:
Hi, I'm in a middle of writing something like 'exception handler wraper' for a set of different methodes. The case is that I have ca. 40 methods form web servicem, with different return values (and types), and with out parmeters. What I want to do is to support each method call with exception (http 404, soap exception, and other types of exceptions) and wrap it with try & catch (a lots of catch ;-)
11
3430
by: dahuzizyd | last post by:
Hi all: I think I had a problem with using out parameter , why the instance of 'SubClass' can't convert to 'BaseClass' ? my code is : ---------------------------------------------- using System; namespace ConsoleApplication2 { class Class1
6
5065
by: nick | last post by:
For example: public static void FillRow(Object obj, out SqlDateTime timeWritten, out SqlChars message, out SqlChars category, out long instanceId)
1
12361
by: ccarter45 | last post by:
What am I missing? import java.util.Scanner; public class MathTutor { public static void main( String args ) { int choice; choice = printMenu();
0
8838
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
9577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
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...
1
9339
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,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
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...
0
6081
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();...
1
3322
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
2225
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.