It is difficult to point out the answer.
When you say a serious error occurs , I assume that you are seeing an OutOfMemoryException .
The Garbage Collector (GC) starts when the Framework allocates GC time or calls it.
If you create / use memory faster than the Framework can invoke the GC, you may run out of memory - especially in a CF application.
The MSDN link above states the following:
The .NET Framework garbage collector manages the allocation and release of memory for your application. Each time you use a new operator to create an object, the runtime allocates memory for the object from the managed heap. As long as the address space is available in the managed heap, the runtime continues to allocate space for new objects. However, the memory is not infinite. In the end, the garbage collector must complete the build to free some memory. The garbage collector optimization mechanism determines the best time to complete the collection based on the allocations made. When the garbage collector performs the collection, it checks the objects in the managed heap that are no longer used by the application and performs the necessary operations to restore their memory.
To get around this, you will need to free up resources as they are completed. If you need this data at some later point, you can save the resource to some medium (flash data, hard disk, etc.) for later search.
You can read more about this on Stephen Pratshnerโs blog entitled .Net Compact Framework Garbage Collector Overview .
source share