Can garbage collection after writing XML files larger than 100MB cause an application to freeze?

StackOverflow https://stackoverflow.com/questions/13270244

質問

So, I wrote a WPF application that takes in all sorts of data from a database, then using Code Synethesis it writes XML files based off of the data. The problem is, sometimes after it finishes writing, the application just seems to hang there, with the Windows Cursors.Wait icon and if I click in the application it freezes up completely and I have to Close Process on the application from Task Manager.

Looking at a completed XML document (*.xml), its about 100MB to 200MB (including tags and everything), depending on the type of data. Is it possible that the garbage collection is the reason why the application seems to be busy for so long? Sometimes it sits for +30mins and it'll eventually resolve, but no idea why.

役に立ちましたか?

解決

Garbage collection will not be the reason for this. GC can easily collect millions of objects per second, and most likely you don't have that many sitting around.

If you can repeat this while debugging inside Visual Studio, hit Break All to break execution. Then, use the Threads tool window (Ctrl+D,T) to check all running threads, and switch to each one to see where it is waiting. If you GUI is frozen, it may likely be the inside the Main Thread (GUI thread).

Most likely, you have a deadlock of some sort, and your app is waiting to acquire a lock.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top