Click here to Skip to main content
15,894,740 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.IO.File.Delete() Pin
M Riaz Bashir30-Sep-07 20:50
M Riaz Bashir30-Sep-07 20:50 
AnswerRe: System.IO.File.Delete() Pin
yogesh_kumar_agarwal30-Sep-07 21:05
yogesh_kumar_agarwal30-Sep-07 21:05 
QuestionTime values in datagrid Pin
yogesh_kumar_agarwal30-Sep-07 20:25
yogesh_kumar_agarwal30-Sep-07 20:25 
AnswerRe: Time values in datagrid Pin
Mandaar Kulkarni1-Oct-07 0:33
Mandaar Kulkarni1-Oct-07 0:33 
QuestionMSBuild command line Pin
Abhi Lahare30-Sep-07 20:23
Abhi Lahare30-Sep-07 20:23 
AnswerRe: MSBuild command line Pin
Mandaar Kulkarni30-Sep-07 21:11
Mandaar Kulkarni30-Sep-07 21:11 
GeneralRe: MSBuild command line Pin
Abhi Lahare1-Oct-07 0:07
Abhi Lahare1-Oct-07 0:07 
Questionproblem with System.OutOfMemoryException Pin
Super Lloyd30-Sep-07 20:21
Super Lloyd30-Sep-07 20:21 
In my code I am manipulating/creating/destroying in memory representation of big XML file (as in a few MB of CDATA in them (embeded bitmaps)).

At some stage (and I am in no way under any memory stress as my application is using only about 500MB of memory and I have 1GB free, without counting the virtual memory) I have this out of memory exception happening, in code snippet looking like that:
=====
  public static void WriteXml(System.Xml.XmlWriter writer, IEnumerable<string> resources, IResourceProvider provider)<br />
  {<br />
   writer.WriteStartElement("Resources");<br />
<br />
   writer.WriteElementString("ResourceProvider", provider.ID.ToString());<br />
   List<string> resourcesWritten = new List<string>();<br />
   foreach (string resource in resources)<br />
   {<br />
    if (resourcesWritten.Contains(resource))<br />
     continue;<br />
    writer.WriteStartElement("Resource");<br />
    byte[] data = provider.LoadData(resource);<br />
    writer.WriteElementString("ResourceName", resource);<br />
    string b64Data = Convert.ToBase64String(data);<br />
    // ========== OutOfMemoryException below<br />
    writer.WriteElementString("base64Data", b64Data);<br />
    writer.WriteEndElement();<br />
    resourcesWritten.Add(resource);<br />
   }<br />
   writer.WriteEndElement();<br />
  }
=====
the error stack is:
====
  System.Xml.dll!System.Xml.XmlWellFormedWriter.WriteString(string text) + 0x55 bytes <br />
  System.Xml.dll!System.Xml.XmlWriter.WriteElementString(string localName, string ns, string value) + 0x29 bytes <br />
  System.Xml.dll!System.Xml.XmlWriter.WriteElementString(string localName, string value) + 0xb bytes <br />
> NovaMind.Data3.dll!NovaMind.Data.ResourcesHelper.WriteXml(System.Xml.XmlWriter writer = {System.Xml.XmlWellFormedWriter}, System.Collections.Generic.IEnumerable<string> resources = {NovaMind.Data.NMMapBranch.get_ResourcesInUse}, NovaMind.Data.IResourceProvider provider = {NovaMind.Data.NMDocumentPackage}) Line 27 + 0x13 bytes C#
====
When I look at the internal of the various object involved with the debugger I could see that:
data.Length ~= 7 Mb (~ 7 e+6)

and "Writer" is wrapper around a StringBuilder which MaxCapacity is around 2 GB (2e+9) and which current Length is "only" about 25 Mb (25e+6).

Now, all these numbers are huge I agree, however my memory isn't stressed at all (i still used much less than my physical memory, virtual memory notwithstanding)).
Any idea why I have OutOfMemory exceptions? how to get rid of them?
AnswerRe: problem with System.OutOfMemoryException Pin
Martin#30-Sep-07 21:47
Martin#30-Sep-07 21:47 
GeneralRe: problem with System.OutOfMemoryException Pin
Super Lloyd1-Oct-07 13:24
Super Lloyd1-Oct-07 13:24 
QuestionSQL Problem. Pin
Janu_M30-Sep-07 20:03
Janu_M30-Sep-07 20:03 
AnswerRe: SQL Problem. Pin
N a v a n e e t h30-Sep-07 20:29
N a v a n e e t h30-Sep-07 20:29 
GeneralRe: SQL Problem. Pin
Janu_M1-Oct-07 2:01
Janu_M1-Oct-07 2:01 
AnswerRe: SQL Problem. Pin
Andrei Ungureanu30-Sep-07 21:26
Andrei Ungureanu30-Sep-07 21:26 
GeneralRe: SQL Problem. Pin
Janu_M1-Oct-07 2:02
Janu_M1-Oct-07 2:02 
QuestionDelete/Remove any particular File from any particular Folder/Direcotory Pin
M Riaz Bashir30-Sep-07 19:55
M Riaz Bashir30-Sep-07 19:55 
AnswerRe: Delete/Remove any particular File from any particular Folder/Direcotory Pin
Tamimi - Code30-Sep-07 20:01
Tamimi - Code30-Sep-07 20:01 
GeneralRe: Delete/Remove any particular File from any particular Folder/Direcotory Pin
M Riaz Bashir30-Sep-07 20:23
M Riaz Bashir30-Sep-07 20:23 
QuestionAccessing controls form class file problem Pin
rakeshpckm30-Sep-07 19:42
rakeshpckm30-Sep-07 19:42 
AnswerRe: Accessing controls form class file problem Pin
N a v a n e e t h30-Sep-07 20:06
N a v a n e e t h30-Sep-07 20:06 
QuestionFinding functions with no reference Pin
N a v a n e e t h30-Sep-07 19:19
N a v a n e e t h30-Sep-07 19:19 
AnswerRe: Finding functions with no reference Pin
Christian Graus30-Sep-07 19:29
protectorChristian Graus30-Sep-07 19:29 
GeneralRe: Finding functions with no reference Pin
N a v a n e e t h30-Sep-07 19:44
N a v a n e e t h30-Sep-07 19:44 
QuestionExit application Pin
sonigirish30-Sep-07 19:07
sonigirish30-Sep-07 19:07 
AnswerRe: Exit application Pin
N a v a n e e t h30-Sep-07 19:21
N a v a n e e t h30-Sep-07 19:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.