views:

21

answers:

2

My .NET CF 3.5 application receives an Out of memory exception when DOM processing an xml file of size 2MB. Now I understand that this should be changed to SAX processing, but I was wondering why this error is received.

From http://blogs.msdn.com/b/mikezintel/archive/2004/12/08/278153.aspx, "Windows CE creates one additional virtual address space, 1G in size, for large allocations." "The 32MB application virtual address space can come under a lot of pressure by a large application, and if it becomes sufficiently fragmented, can lead to OOM errors even when there is free physical memory."

Does this mean that if my application's heap size, including the DOM, takes up more memory than 32 MB, the application will crash, but then can't it use more of the the 1GB virtual address space for this allocation?

A: 

From what I remember, all normal data (and associated objects) live in the 32Mb virtual address space for the application -- to use the 1Gb additional address space, you have to look into memory mapping. Of course, the alternate in your case would be stream based processing.

Rowland Shaw
A: 

We have found this to be a very useful explanation (and solution!) for CF memory woes. We're using this methodology successfully on apps that used to have problems using Intermec utilities (we had P/Invoke issues -- the VM space for our app was fully utilized therefore the P/Invoke dlls were not able to be loaded.)

http://robtiffany.com/mobile-development/memmaker-for-the-net-compact-framework

Steve