OutOfMemoryException: How to give an application more RAM?

M

Manfred Denzer

Hello!

My PDA (Ikôn by Psion Teklogix) with Windows Mobile 6 has 128MB RAM.
I develop with C# and the .NET Compact Framework in Microsoft Visual
Studio 2005.

If I load a big XML in my application, I get an OutOfMemoryException.
I check the memory in my application with "GC.GetTotalMemory(true)".
Bevor I load the XML, it is 850.000 and after it is 3.500.000. Is this
to much?
Is it possible to give an application more RAM?
In Java it is possible with "javaw.exe -Xmx128m", so I hope, there is
a chance in C# too :)

Thank you very much for your help!
Manfred Denzer
 
C

Chris Tacke, eMVP

If I load a big XML in my application, I get an OutOfMemoryException.
I check the memory in my application with "GC.GetTotalMemory(true)".
Bevor I load the XML, it is 850.000 and after it is 3.500.000. Is this
to much?

Obviously it is - you're getting an out of memory exception.
Is it possible to give an application more RAM?

No. You simply have to use less. You don't say how large your XML file is,
but I'm guessing somewhere between massive and obscene. You need to think
of anotehr strategy. Maybe loading only parts of it at a time. Maybe
pushing less XML in the first place. Only you know which route will work.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
M

Manfred Denzer

Thank you very much for your reply.

I use XML files to communicate between server and the mobile client.
In one case, I have to transfer a lot of texts and images to the PDA.
At the moment, this XML file has a size of 650 KB, but can dynamic
grow, e.g. it could be 3-4 times bigger.
In the XML file, images are saved as a very long string. I saved this
string in my class and convert it to an image not until the image
should be displayed in a PictureBox. Is it a problem to save very long
strings in my class?
 
C

Chris Tacke, eMVP

So you have the XML, the class with a UUENCODed string or sililar, and then
the actual bitmap itself. Yes, I can certainly see why this could use a
large amount of memory. You need to find a better way of handling it. I'd
be inclined to convert the images when you receive them to actual image
files in the file system. Even as Bitmap objects in the calls they'll be
smaller than the Unicode string representation Why would you carry them
around as giant strings?


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
C

Christof Wollenhaupt

Hi Manfred,
If I load a big XML in my application, I get an OutOfMemoryException.

What are you doing with the XML string? If you don't need to do any complex
conversions or queries, you can use the XmlReader class instead of loading
the XML document into a DOM. It's a bit more work, but the reader doesn't
need to create an in memory tree of the XML document and therefore requires
less resources.
 
M

Manfred Denzer

I carry giant strings because I thought, that strings are more
efficient than Bitmap objects...
OK, I will try to save the images in the file system of the device!
That's a good idea! Thank you!
:)
 
M

Manfred Denzer

At the moment, I load the XML with the class XmlDocument and the
method LoadXml(string).
I will have a look at the class XmlReader! Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top