.net - OutOfMemoryException When Creating Huge String?
Sep 17, 2010
When exporting a lot of data to a string (csv format), I get a OutOfMemoryException. What's the best way to tackle this? The string is returned to a Flex Application.What I'd do is export the csv to the server disk and give back an url to Flex. Like this, I can flush the stream writing to the disk.Update:String is build with a StringBuilder:
StringBuilder stringbuilder = new StringBuilder();
string delimiter = ";";
bool showUserData = true;
[code]...
View 5 Replies
Similar Messages:
Feb 13, 2011
Is it possible to create a list from a string which is comma separated ?
So the list would look like
Dim list1="Coffee, Tea, Milk"
Output would be :
1. Cofee
2 Tea
3 Cofee
We all know ho to to in html :
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
I just can't find an example of converting the string?
View 2 Replies
Apr 12, 2012
currently i have db name , server name & coonection credentials for sql daTAbase hardcoded in webconfig but i need to create a dynamic connection string in which db name will change currenly i have a main .aspx with a button & on its click event i get the connection string frm webconfig and move on to next page
wht i need is in the main page i need to populate all the db of a particullar server in a dropdown the user will first select the db frm drpdown & click the button & with the db name frm dropdown connection string shld be formed
View 1 Replies
Feb 22, 2011
I need to create a public bool that checks a string for items in an arraylist.
Here is a vague sample of what I'm talking about..
[Code]....
I'm not experienced enough with the foreach statement to quite figure out what I'm doing wrong here.
View 5 Replies
Jun 4, 2010
I am trying to solve a problem that involves creating a very large XML string and stream that to browser. Right now i am using stringbuilder class. Here is the sample code
here i am using only just one property.
[code]....
total length of the final string will be 120MB or so.
With this code i am getting out of memory errors intermittently. To resolve this issue ..i am planning to create a HTTP handler for streaming XML output to browser.
View 3 Replies
Oct 19, 2010
String is immutable and StringBuilder is mutable. So if I change the value of a string a new memory created with the new value, whereas in StringBuilder it updates its memory location rather than creating a new memory location. So for large concatenation stringBuilders are preffered. But when I create a new String object, a fixed memory is created. And any changes will update its memory location, rather than creating a new memory location.
For e.g.
String s = new String();
s = String.Empty;
for ( int i=0;i<100; i++)
{
//s = s + "test" + i.ToString();
s =string.Concat(s, "test" + i.ToString()); ///This is effecient compared to previous step
}
Now instead of String class I will use a StringBuilder class.
StringBuilder s = new StringBuilder(String.Empty);
for ( int i=0;i<100; i++)
{
//s = s + "test" + i.ToString();
s.append( "test" + i.ToString());
}
View 13 Replies
Sep 6, 2010
Does anyone know why this happens?
[URL]
It was running fine and then all of a sudden this message poped up.
View 2 Replies
Nov 25, 2010
I have an XElement object that contains about 120MB of data. The XML consists of approx 6000 elements of about 20kb each.
I am trying to call XElement.ToString() as I need to return the OuterXml in a webservice.
I am getting a System.OutOfMemoryException.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown:
at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
at System.Text.StringBuilder.Append(Char[] value, Int32 startIndex, Int32 charCount)
at System.IO.StringWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.Xml.XmlEncodedRawTextWriter.FlushBuffer()
at System.Xml.XmlEncodedRawTextWriter.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)
at System.Xml.XmlEncodedRawTextWriter.WriteString(String text)
at System.Xml.XmlEncodedRawTextWriterIndent.WriteString(String text)
at System.Xml.XmlWellFormedWriter.WriteString(String text)
at System.Xml.XmlWriter.WriteAttributeString(String prefix, String localName, String ns, String value)
at System.Xml.Linq.ElementWriter.WriteStartElement(XElement e)
at System.Xml.Linq.ElementWriter.WriteElement(XElement e)
at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
at System.Xml.Linq.XNode.GetXmlString(SaveOptions o)
at System.Xml.Linq.XNode.ToString()
I have the same data in an XmlDocument and can call XmlDocument.OuterXml without a problem. I can also call XElement.Save() to save the XML to a file without a problem.
View 2 Replies
Feb 23, 2011
I have to pull 150K records from DB. I am using da.Fill(ds,"Query") and its throwing system.outofmemoryexception.
Dim daGrid As New SqlDataAdapter(sqlcmd_q)
daGrid.Fill(dsGrid, "Query")
daGrid.Dispose()
I need this datatable only. I cannot use XML. because I need assign this to MSChartControl to display ScotterPlot.
View 2 Replies
Feb 17, 2010
I have hosted some 5 applications on IIS in my server.
After sometimes I am getting System.OutOfMemoryException error due to out of memory in ASP.NET Temp Folder.
Is there any way to clear it automatically or any setting for this.
View 3 Replies
Jun 22, 2010
I am getting a system.outofmemory exception in my code:
[code]....
how I go about diagnosing and fixing this exception?
View 2 Replies
Jun 1, 2010
I just published my website to a server. Using this server I get the following error when I click on an image to view it:
System.OutOfMemoryException: Out of memory.
I didn't had the error when I worked on my local server.
View 4 Replies
Jul 9, 2010
I am facing a problem wherein, whenever I am trying to export a large recordset to excel (over 50k records) I am getting the System.OutOfMemoryException. I want to know a couple of things :
1. How do I handle this exception as try - catch does not seem to work?
2. I am pasting sample code. I just want to know if there is a better way of doing this :
[code]....
View 5 Replies
Nov 15, 2010
When I refresh the entity framework with big table, I get the System.OutOfMemoryException.
Is there any better way to refresh the EF with big tables? I'm using .Net 3.5
View 5 Replies
Oct 14, 2010
I have a website that I have run for years running a custom built CMS. It has had no problems ever. I decided to create a demo (temporary url) of the CMS using the exact same website. Only people I give access to would be able to login and change it, so it basically is not in use for the most part.
I tried this demo site the past few days, and I noticed that I kept getting System.OutOfMemoryException errors. I would wait for an hour or so, then it would work. Next day, same thing.
What could explain this? 2 exact same websites....one that is used all the time (no memory issues), and one that is hardly ever used (memory issues). Doesn't really make sense to me.
View 6 Replies
Sep 20, 2010
I stuck in the issue of exporting excel it gives error System.OutOfMemoryException in excel 2007 we cam export 1000000 rows but while exporting more then 250000 rows its gives the error the logic to upload the excel as i am using is
[code]....
View 1 Replies
Aug 3, 2010
We have an asp.net 2.0 application in which we get the exception of type 'System.OutOfMemoryException' whenever value is retrieved or stored in viewstate. It does not happen when we test it in local PC but when it is deployed on application server, the exception is thrown.
View 2 Replies
Feb 8, 2010
I have one issue , on that page i have Gridview ie: binding data(by making relationship b/w two tables ) ie: each row contains 75 EasyListbox control so it will be visible as per the condition ie: getting from Database.
But when the page_Loads on that page - First rows shows correctly ie: when i click on paging for Second page - it shows error like this
[code]....
View 13 Replies
Jan 20, 2011
I am getting Error Msg Given Below..After Uploading My WebApplication..whenever i try to access my webapplication? what is the exactly reason of this Error. Some time it solved automatically when i try some time later.
Server Error in '/' Application.
Exception of type 'System.OutOfMemoryException' was thrown.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
View 1 Replies
Feb 22, 2010
i have a file upload control in my page and have set the max file size in web.config to 1 GB (this is an intranet app).
However, when I try to upload a 280 MB file, it throws System.OutOfMemoryException. The server has 4 GB of RAM and plenty of disk space.
View 4 Replies
Apr 8, 2010
I have an ashx handler with the following code. The idea is to hide the path of the file and prompt a download
[code]....
This works fine for some files however on others i get
Exception of type 'System.OutOfMemoryException' was thrown.
View 2 Replies
May 11, 2010
I'm using Filestream for read big file (> 500 MB) and I get the OutOfMemoryException. Any solutions about it??
I want this in my app:
Read DATA from Oracle
Uncompress file using FileStream and BZip2
Read file uncompressed and send it to asp.net page for download. When I read file from disk, Fails !!! and get OutOfMemory.
. My Code is:
using (var fs3 = new FileStream(filePath2, FileMode.Open, FileAccess.Read))
{
byte[] b2 = ReadFully(fs3, 1024);
}
// http://www.yoda.arachsys.com/csharp/readbinary.html
public static byte[] ReadFully(Stream stream, int initialLength)
{
// If we've been passed an unhelpful initial length, just
// use 32K.
if (initialLength < 1)
{
initialLength = 32768;
}
byte[] buffer = new byte[initialLength];
int read = 0;
int chunk;
while ((chunk = stream.Read(buffer, read, buffer.Length - read)) > 0)
{
read += chunk;
// If we've reached the end of our buffer, check to see if there's
// any more information
if (read == buffer.Length)
{
int nextByte = stream.ReadByte();
// End of stream? If so, we're done
if (nextByte == -1)
{
return buffer;
}
// Nope. Resize the buffer, put in the byte we've just
// read, and continue
byte[] newBuffer = new byte[buffer.Length * 2];
Array.Copy(buffer, newBuffer, buffer.Length);
newBuffer[read] = (byte)nextByte;
buffer = newBuffer;
read++;
}
}
// Buffer is now too big. Shrink it.
byte[] ret = new byte[read];
Array.Copy(buffer, ret, read);
return ret;
}
View 1 Replies
Sep 23, 2010
I'm Using a DataReader to Read about 100,000 records, my code look like :
[Code]....
I have a per row computation in reading the rows on GetMyType2Info() method, and this method also another method that I return only one record by ExecuteReader(). the problem is that when the MyTypeList (List<T>) has about 21,000 Items of MyType (<T>) System.OutOfMemoryException is thrown. wanted to know how to resolve this and wanted to know more about the maximum size of List<T> capacity. in addition the execution of the main Query with 100,000 records take about 4 seconds in SQLServer a record has only types of nvarchar , float,datetime and int
View 1 Replies
Nov 30, 2010
I am getting this exception whenever i tried to delete the WCF Service reference in project.I cannot even update it.Our WCF Service is bit huge and looks like this is causing the issue.I Start/Stopped IIS web server but still i cant get rid of it.
View 1 Replies
Apr 6, 2010
Does it have any major effect on performance/ memory if my web.config is really huge (say, 1000+ entries in <appSettings>)? Is it a good idea to maintain a different custom xml config file for all business specific settings for my app?
View 3 Replies