We have a .net 1.1 application that is displaying very strange behaviour with respects to garbage collection. The application is designed to pull data from a SQL database and generate a report out of this. The database is relatively large (roughly 30G of data) and the application needs to go through fairly large portions of this data to generate the output. We use a cache with weak links to reduce the actual SQL queries that are being run, which is a huge increase in performance under normal circumstances.
Now, the issue we are having is that the application starts to garbage collect excessively (on the order of 10 gen-0 GCs, and around 2 gen-1 GCs per second) randomly during execution. Normally, the application can end up using around 1GB of memory, but once this garbage collection issue appears, the application stops at around 100MB.
When this GC issue crops up, our cache with weak references is dropped and the application starts hammering the SQL server with queries and ends up slowing down to a crawl.
I have included a dump of "!eeheap -gc" from WinDbg when the server is in this state at the bottom of this post. As you can see, there are 8 cores on this server, and each core has about 1MB of data in the heap (all in gen-2 due to this excessive GC).
There is about 3GB of free physical RAM on the server, and the .net process is, as I mentioned above, using about 100MB in total.
Doing a "!dumpheap -stat" shows that a lot of the data in the heap is strings (on the order of 100,000 of them) which to me doesn't seem too excessive.
My question is, why does the application enter this state of frenzied GC calls when there should be plenty of memory left for the application At times it runs fine, and grows up to the expected 1GB of memory usage while at other times it goes straight into this GC-frenzy mode.
Any insight into what may cause this would be appreciated. If you have suggestions on what to read to figure out what's going on and hopefully fix the issue, I'd be happy for a link to it or an ISBN for a book describing it.
Thank you in advance!
0:045> !eeheap -gc
Number of GC Heaps: 8
------------------------------
Heap 0 (0x000d2468)
generation 0 starts at 0x0286ed40
generation 1 starts at 0x02841914
generation 2 starts at 0x027b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x027b0000 0x027b0030 0x0286ed4c 0x000bed1c(781,596) 0x01c2f000
Large object heap starts at 0x127b0030
segment begin allocated size reserved
0x127b0000 0x127b0030 0x128051a0 0x00055170(348,528) 0x007aa000
Heap Size 0x255524(2,446,628)
------------------------------
Heap 1 (0x000d2b88)
generation 0 starts at 0x04852d2c
generation 1 starts at 0x048220fc
generation 2 starts at 0x047b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x047b0000 0x047b0030 0x04852d38 0x000a2d08(666,888) 0x01c1f000
Large object heap starts at 0x12fb0030
segment begin allocated size reserved
0x12fb0000 0x12fb0030 0x12fcd9e0 0x0001d9b0(121,264) 0x007df000
Heap Size 0xcca7c(838,268)
------------------------------
Heap 2 (0x000d3698)
generation 0 starts at 0x06839064
generation 1 starts at 0x06834014
generation 2 starts at 0x067b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x067b0000 0x067b0030 0x06839070 0x00089040(561,216) 0x01c9f000
Large object heap starts at 0x137b0030
segment begin allocated size reserved
0x137b0000 0x137b0030 0x137b0030 0x00000000(0) 0x007a4000
Heap Size 0x89040(561,216)
------------------------------
Heap 3 (0x000d4180)
generation 0 starts at 0x088949a0
generation 1 starts at 0x0887662c
generation 2 starts at 0x087b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x087b0000 0x087b0030 0x088949ac 0x000e497c(936,316) 0x01c5f000
Large object heap starts at 0x13fb0030
segment begin allocated size reserved
0x13fb0000 0x13fb0030 0x13fb0030 0x00000000(0) 0x007e2000
Heap Size 0xe497c(936,316)
------------------------------
Heap 4 (0x000d4c68)
generation 0 starts at 0x0a8759e4
generation 1 starts at 0x0a87097c
generation 2 starts at 0x0a7b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x0a7b0000 0x0a7b0030 0x0a8759f0 0x000c59c0(809,408) 0x01bef000
Large object heap starts at 0x147b0030
segment begin allocated size reserved
0x147b0000 0x147b0030 0x147b0030 0x00000000(0) 0x007c2000
Heap Size 0xd3d84(867,716)
------------------------------
Heap 5 (0x000d5750)
generation 0 starts at 0x0c8675b0
generation 1 starts at 0x0c826948
generation 2 starts at 0x0c7b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x0c7b0000 0x0c7b0030 0x0c8675bc 0x000b758c(750,988) 0x01caf000
Large object heap starts at 0x14fb0030
segment begin allocated size reserved
0x14fb0000 0x14fb0030 0x14fb0030 0x00000000(0) 0x007c2000
Heap Size 0x20cfe8(2,150,376)
------------------------------
Heap 6 (0x000d6028)
generation 0 starts at 0x0e8aee0c
generation 1 starts at 0x0e8a1ffc
generation 2 starts at 0x0e7b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x0e7b0000 0x0e7b0030 0x0e8aee18 0x000fede8(1,043,944) 0x01bff000
Large object heap starts at 0x157b0030
segment begin allocated size reserved
0x157b0000 0x157b0030 0x157b0030 0x00000000(0) 0x007c2000
Heap Size 0x106de8(1,076,712)
------------------------------
Heap 7 (0x000d6b10)
generation 0 starts at 0x1087d144
generation 1 starts at 0x10852cf8
generation 2 starts at 0x107b0030
ephemeral segment allocation context: none
segment begin allocated size reserved
0x107b0000 0x107b0030 0x1087d150 0x000cd120(839,968) 0x01baf000
Large object heap starts at 0x15fb0030
segment begin allocated size reserved
0x15fb0000 0x15fb0030 0x15fb0030 0x00000000(0) 0x007df000
Heap Size 0xcd120(839,968)
------------------------------
Reserved segments:
------------------------------
GC Heap Size 0x9445d0(9,717,200)