Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- From: "Robert Simpson" <rmsimpson@xxxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 13:04:56 -0700
Your desktop can page memory to and from disk as needed in order to fulfill
an allocation request. What medium do you suppose CE can page to?
5mb may not seem like much, but your app isn't the only one installed on the
device, and may not be the only one running. Best to play nice and code for
the hardware limitations of the platform rather than assume that any
service, memory and capability is at your app's sole disposal. When coding
for CE you're going to have to make conscious efforts to limit the memory
and resources you allocate, and code for the fact that an allocation request
could fail.
Robert
"Chris DiPierro" <cdipierr@xxxxxxxxxxxxxxxxxx> wrote in message
news:eyMFvuF$GHA.3312@xxxxxxxxxxxxxxxxxxxxxxx
I understand that there are ways around it, but I think we have differing
opinions here. I can in fact allocate 300MB or so in a desktop application
w/o a problem (1/7th of my address space), so I guess I'd assume a platform
being presented as an enterprise-capable one would be able to do the same.
But even so, let's be realistic, in this day and age we're not moving 300MB
data files very often, but 5MB is hardly out of the realm of realism.
I've been doing embedded system development for the better part of 10
years now, so I guess I was just expecting too much of these modern
platforms.
In any event, thank you for the informative reply.
Paul G. Tobey [eMVP] wrote:
These are little tiny devices, not modern PCs where you just dump every
last piece of data you can think of and who cares, there's another 512MB
of RAM and ample hard disk for use with virtual memory laying around
anyway. You are programming for an embedded system. It's not an
embedded system of ten years ago, when you'd be lucky to have a 32-bit
processor, let alone multi-MB flash disks, but it's still a small device
and you have to program it with its limitations in mind. I'm not saying
that a 5MB XML file is out of the question, just that trying to process a
5MB XML object in RAM is not a smart way to start your work.
No, the limit will depend on the total number and size of allocations,
both in the system as a whole and the application which you are running.
The address space for your process is 32MB, regardless of how much RAM is
in the device, so you're presently using about 1/7 of the total *address
space* available to you for just this one object (imagine using 1/7 of
the 2GB address space of a process on your PC!). Not only that, but some
of that 32MB address space is used for DLLs that you are using, etc. The
lack of virtual memory for data means that you can't be blissfully
ignorant of what's really going on under the covers, if you can even when
virtual memory is present.
Paul T.
"Chris DiPierro" <cdipierr@xxxxxxxxxxxxxxxxxx> wrote in message
news:%237wzDeF$GHA.4300@xxxxxxxxxxxxxxxxxxxxxxx
You're right that it's characters (so 5MB). As for why in RAM, I think
the counter to that is why not? The more we do with WM devices, the more
we want them to behave like other mobile devices (ie. Tablets, UMPCs),
so it's not atypical to be moving large amounts of data.
As for the specific issue, I probably will address it via file, but is
there some sort of known hard limit? In my case, I'm using the emulator,
and program memory indicates 65+ MB free when the error is thrown. To me
that seems unintuitive.
Paul G. Tobey [eMVP] wrote:
Seems like any single memory object that's 2.5MB (or is that
2.5Mcharacters, which would be 5MB), is a non-starter on a little
device like a Pocket PC. Why do you want it in RAM, anyway? Why not
write it to a file? At least there's a chance that a multi-MB file can
exist in the system.
Paul T.
"Chris DiPierro" <cdipierr@xxxxxxxxxxxxxxxxxx> wrote in message
news:uQWsHWF$GHA.4888@xxxxxxxxxxxxxxxxxxxxxxx
It seems as if there's a hard limit in XMLTextWriter that's causing me
a headache.
If I create an XMLTextWriter from a StringWriter, once the string gets
to be about 2.5MB in length, the XMLTextWriter will OutOfMemory
exception. The simple code listed below causes this problem.
Anyone know of a workaround / solution?
private void button1_Click(object sender, EventArgs e)
{
System.IO.StringWriter sWriter = new System.IO.StringWriter();
System.Xml.XmlTextWriter xWriter = new
System.Xml.XmlTextWriter(sWriter);
xWriter.WriteStartElement("Test");
string s = new string('A', 10000);
while (true)
{
xWriter.WriteStartElement("ABC");
xWriter.WriteString(s);
System.Diagnostics.Debug.WriteLine("Length: " +
sWriter.ToString().Length);
xWriter.WriteEndElement();
}
xWriter.WriteEndElement();
}
.
- References:
- CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- From: Chris DiPierro
- Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- From: Paul G. Tobey [eMVP]
- Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- From: Chris DiPierro
- Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- From: Paul G. Tobey [eMVP]
- Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- From: Chris DiPierro
- CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- Prev by Date: Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- Next by Date: Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- Previous by thread: Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- Next by thread: Re: CF Bug / Limitation in XMLTextWriter (OutOfMemory)
- Index(es):
Relevant Pages
|