Re: Out of memory error
From: Schoo (scott.schuman_at_nospam.ma-hc.com)
Date: 03/09/04
- Next message: Mark: "Re: Development and production url address setting in asp.net project"
- Previous message: Verde: "Re: Easy Frames Question"
- In reply to: Steven Cheng[MSFT]: "RE: Out of memory error"
- Next in thread: Dennis Homann: "Re: Out of memory error"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 9 Mar 2004 10:49:44 -0600
Steven,
Thank you for your response. After pursuing your ideas for almost 3 hours
this morning here is what I have come up with:
Memory on the server is 261,648KB. However, I am not clear on which memory
the compiled code is using to run its logic. At this point I am assuming it
is the server that is running short of memory and not the client because of
the message on the server log.
In response to your 2nd point, I should have mentioned that I have been
using a stringbuilder and not a string all along.
I spent most of the time this morning testing and seeing if I can narrow
down where the problems is. I must also add that my code is not very
complicated and should not be difficult to duplicate a similar situation on
your system. Maybe if you knew more information it would help in your
diagnosing the problem:
I have a stored proc (SQL2000) returning 376 records of which I am using 6
columns. All of the columns return varchars (except one that is an
integer). I am using a datareader through the MS Application Data Block
which returns the results of the stored proc. I then scroll through the
records and form the contents of a grid using <table>, <tr>, and <td> tags.
Normally I would use a dataset and bind it to a grid control, but in this
case the specification asks for data in different cells based on the values
of other cells, which means I can't just bind the data to a grid, and also
they want it to appear as an Excel spread*** in the browser, so I have a
line in the Page_Load procedure that reads: "Response.ContentType =
"application/vnd.ms-excel". I DID try to pull out that line to see if it
would run but that did not work either.
Placing break-points in various places, I learned that the code apparently
does not get to the point where it returns the data to the page ("Return
strResponse.ToString"). [Yes, I converted out the "response.write
(strResponse.ToString)" to create a function instead of a procedure, but it
didn't seem to make a difference.] So, when there is 300 records that need
to be processed, it runs fine, but if there are 376 records it never gets to
the end of the 'While' loop.
This is very strange! This isn't alot of records... when this goes into
production I expect hundreds of thousands of records to scroll through.
Even if I increase memory allocation on the server and that works, it would
only be a temporary solution. Is there another technique that would present
this as an excel spread*** better? I have some experience creating Excel
spreadsheets programatically using VB but it's been years since I had to do
that and the method I am trying to copy here was originally ASP logic that
worked with Access which I converted to a datareader and ASP.NET with a SQL
Server 2000 datasource. This shouldn't be this difficult... the answer
should be obvious, so what am I doing wrong?
Scott
"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:zeK837XBEHA.2304@cpmsftngxa06.phx.gbl...
> Hi Scott,
>
> Thanks for posting in the community!
> From your description,you used Response.Write to render a certain page's
> output content from a certain
> dataset which contains hundreds of records. Also you used the string to
> manipulate the output content, however,
> when running, you encoutnered out of memory exception. And from the
> eventlog , you found that
> it did caused by the memory useage exceed 60% of the avaliable physical
> memory and the aspnet worker process
> recycled. So you wonder :
> 1. how to allow him still wirte out all the strings generated from the
> dataset to the output stream
> 2. change the limiation of the memory useage of the aspnet worker process
> If there is anything I misunderstood, please feel free to let me know.
>
> As for this problem, here are my suggstions:
> 1. From the description proivded by your eventlog. It occured when 153 MB
> memory is used and exceed the 60% limitation. Does your machine have 256MB
> physical memory installed? If so, we can confirm that the problem(out of
> menory exception and workerprocess recycle) is really caused by the memory
> useage. And this memory usage limitation can be configured in the
> machine.config file within the <processModel> element, by default, its
> value is 60%, you can adjust it to larger percent value. You may get the
> detailed info on this via the following reference in MSDN:
> #<processModel> Element
>
http://msdn.microsoft.com/library/en-us/cpgenref/html/gngrfProcessmodelSecti
> on.asp?frame=true
>
> 2. Though we can change the memory usage limitation of a aspnet
> workerprocess in the above element, I still think this problem is caused
by
> the certain performance issue with in the page which render out the
content
> from dataset. As you mentioned that the DataSet has great amount of
> recoreds and you generate the whole content using the string class, yes?
> Then, do you use many manipulations such as appending string or resize it
> by concat different strings, since the string class's instance is
> unresizeable, such operations will cause a new string instance be created
> and replace the original one, this will cause poor performance and large
> memory useage. I suspect whether this is a potential cause of this issue?
> And there is a class named "StringBuilder" in the System.Text namespace,
> which is helped to provide string manipulate operations and won't
> reallocate new instance when size changed. You may try using StringBuilder
> class to replace the string to improve your performance. Here are some
tech
> articles on using stringbuilder rather than string to improve performance:
>
> #Improving String Handling Performance in .NET Framework Applications
>
http://msdn.microsoft.com/library/en-us/dndotnet/html/vbnstrcatn.asp?frame=t
> rue
>
> #Manipulate Strings Faster in VB.
>
http://msdn.microsoft.com/library/en-us/dnvbpj01/html/gs0107.asp?frame=true
>
> #Using the StringBuilder Class
>
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconusingstringbuilder
> class.asp?frame=true
>
> Please check out the above suggestions and references. If you have any
> further questions, please feel free to post here.
>
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
> Get Preview at ASP.NET whidbey
> http://msdn.microsoft.com/asp.net/whidbey/default.aspx
>
- Next message: Mark: "Re: Development and production url address setting in asp.net project"
- Previous message: Verde: "Re: Easy Frames Question"
- In reply to: Steven Cheng[MSFT]: "RE: Out of memory error"
- Next in thread: Dennis Homann: "Re: Out of memory error"
- Messages sorted by: [ date ] [ thread ]