Lot's of objects on the Large Object Heap on a 64-bit server

My colleague Tess showed me a dump today which I thought was really interesting. The scenario was as follows:

- We have a web application that's been running successfully on a 32-bit server for quite some time. We've now moved to a 64-bit server. The code remains unchanged but we're seeing a lot more objects on the Large Object Heap (LOH). How's that possible?

Well looking closer at the LOH revealed a lot of Object Arrays. These arrays were around the 150 KB-range. An Object Array is nothing but a collection of addresses, each being one DWORD long (32-bit). When we ran the application in a 64-bit environment the addresses were now two DWORDS long. Since the addresses had doubled in size the Object Arrays had also doubled in size. In the 32-bit environment they were around 75 KB, but now they were 150 KB. As I've mentioned before, the limit for when an object goes on the Large Object Heap is 85 KB, so all those arrays now ended up on the LOH.

Since the LOH also isn't compacted this lead to a lot of fragmentation as well. All in all the memory usage of the exact same application saw a significant increase when being executed in the 64-bit environment.

Tess has actually blogged about this in the past. I definitively recommend taking a look at that article.

/ Johan