开发者

.NET Garbage Collector difference between x86 / x64. x64 doesn't collect

I have a WPF application which doesn't seem to garbage collect on x64 systems. I have tested it carefully on x86 machines and I am confident it isn't a programming problem, the memory usage will grow and then will be garbage collected as I expect. The target platform = 'Any CPU'

I have discovered that I can eliminate this behaviour on x64 machines by compiling with the target = 开发者_运维百科x86. x64 or 'Any CPU' fails to release memory.

I also noticed during my investigations that creating a child application domain and manually minimizing the application working set works on x86 but is ignored on x64 systems. Until I set the target = x86.

Does anyone know why this behaviour exists? Do we need to avoid 'Any CPU' or x64?


The Garbage Collector runs when it decides it needs to run. This is typically a matter of the amount of memory usage as well as the amount of free memory.

If the machine(s) in question has a lot of memory, there's no reason for the GC to execute. In x86 machines, memory pressure is usually an issue, since the total allowable memory for a process is much smaller (normally 2gb), and the total for the system is low overall (~3gb). 64bit systems don't have those limitations, so the GC will likely run less often.

Remember, though, this isn't a bad thing - using memory is good, provided you don't run out. More GC collections just reduces your overall performance, and only is a good thing if your running low on available memory. Otherwise, you might as well use the memory that's available.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜