2012-07-09 89 views
2

SignalR存在一個問題(= < v0.5.1),其中請求處於閒置狀態並吸收內存。這似乎已經修正了v0.5.2。但是,可能還有一個額外的問題。SignalR和/或ConcurrentDictionary或SignalR.InMemoryMessage可能發生內存泄漏?

使用WINDBG,我創建了我的新聞傳遞過程的內存轉儲。

首先,這裏是用於SignalR.InMemoryMessage計數和內存消耗:

133099  6388752 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage... 

最後,這裏有用於頂部3存儲器消耗的對象中的值:執行!dumpheap -mt 000007fef995ae68

000007fef9960bb0 79307 140001536 System.Byte[] 
000007fef9956960 1704571 175128912 System.String 
000007fef995ae68 1901299 549202440 System.Object[] 

,我得到了方法表的一個相當長的概要。大多數物體的尺寸相對較小,這是預期的。然而,在轉儲結束,我看到以下內容:

00000001eb0f3220 000007fef995ae68  160  
00000001eb0f3580 000007fef995ae68  40  
00000001eb0f35f0 000007fef995ae68  40  
00000001eb0f3758 000007fef995ae68  56  
00000001eb0f37c8 000007fef995ae68  88  
00000001eb0f3820 000007fef995ae68  48  
00000001eb0f3cc8 000007fef995ae68  40  
00000001eb0f4570 000007fef995ae68  40  
00000001eb0f45e0 000007fef995ae68  40  
00000001eb0f4650 000007fef995ae68  40  
00000001eb0f4de8 000007fef995ae68  176  
00000001eb0f4ed0 000007fef995ae68  40  
00000001eb9b3380 000007fef995ae68  40  
00000001eb9b33c0 000007fef995ae68  40  
0000000237580080 000007fef995ae68 1146888 

於是我繼續前進,做!gcroot 0000000237580080。一些最初的轉儲如下:

0000000237580080 000007fef995ae68 1146888  
total 0 objects 
------------------------------ 
total 0 objects 
Statistics: 
       MT Count TotalSize Class Name 
000007fef995ae68 1901299 549202440 System.Object[] 
Total 1901299 objects 
0:045> !gcroot 0000000237580080 
Note: Roots found on stacks may be false positives. Run "!help gcroot" for 
more info. 
Scan Thread 11 OSTHread 1040 
Scan Thread 24 OSTHread c18 
Scan Thread 26 OSTHread 488 
Scan Thread 27 OSTHread 1144 
Scan Thread 28 OSTHread 14b0 
RSP:57ae0f0:Root: 000000012acea438(MyApp.Newsfeed.Hubs.NewsfeedHub)-> 
    000000012acea5f8(SignalR.GroupManager)-> 
    0000000185a17328(SignalR.Connection)-> 
    000000011f655ed0(SignalR.InProcessMessageBus)-> 
    000000011f656680(System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage`1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]])-> 
    0000000237580080(System.Object[]) 
RSP:57ae100:Root: 000000012acea098(System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[SignalR.Hubs.IDisconnect, SignalR],[System.Threading.Tasks.Task, mscorlib]])-> 
    000000012acea058(System.Func`2[[SignalR.Hubs.IDisconnect, SignalR],[System.Threading.Tasks.Task, mscorlib]])-> 
    000000012ace9ea8(SignalR.Hubs.HubDispatcher+<>c__DisplayClass1a`1[[SignalR.Hubs.IDisconnect, SignalR]])-> 
    0000000185a13640(SignalR.Hubs.HubDispatcher)-> 
    000000011f655ed0(SignalR.InProcessMessageBus)-> 
    000000011f656680(System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage`1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]])-> 
    0000000237580080(System.Object[]) 
RSP:57ae130:Root: 000000012acea438(MyApp.Newsfeed.Hubs.NewsfeedHub)-> 
    000000012acea5f8(SignalR.GroupManager)-> 
    0000000185a17328(SignalR.Connection)-> 
    000000011f655ed0(SignalR.InProcessMessageBus)-> 
    000000011f656680(System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage`1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]])-> 
    0000000237580080(System.Object[]) 
RSP:57ae140:Root: 000000012acea438(MyApp.Newsfeed.Hubs.NewsfeedHub)-> 
    000000012acea5f8(SignalR.GroupManager)-> 
    0000000185a17328(SignalR.Connection)-> 
    000000011f655ed0(SignalR.InProcessMessageBus)-> 
    000000011f656680(System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage`1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]])-> 
    0000000237580080(System.Object[]) 
RSP:57ae188:Root: 000000012ace9ea8(SignalR.Hubs.HubDispatcher+<>c__DisplayClass1a`1[[SignalR.Hubs.IDisconnect, SignalR]])-> 
    0000000185a13640(SignalR.Hubs.HubDispatcher)-> 
    000000011f655ed0(SignalR.InProcessMessageBus)-> 
    000000011f656680(System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage`1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]])-> 
    0000000237580080(System.Object[]) 
RSP:57ae190:Root: 000000012ace9ea8(SignalR.Hubs.HubDispatcher+<>c__DisplayClass1a`1[[SignalR.Hubs.IDisconnect, SignalR]])-> 
    0000000185a13640(SignalR.Hubs.HubDispatcher)-> 
    000000011f655ed0(SignalR.InProcessMessageBus)-> 
    000000011f656680(System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage`1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]])-> 
    0000000237580080(System.Object[]) 
RSP:57ae1a0:Root: 000000012acea438(MyApp.Newsfeed.Hubs.NewsfeedHub)-> 
    000000012acea5f8(SignalR.GroupManager)-> 
    0000000185a17328(SignalR.Connection)-> 
    000000011f655ed0(SignalR.InProcessMessageBus)-> 
    000000011f656680(System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, mscorlib],[SignalR.Infrastructure.LockedList`1[[System.Action`1[[System.Collections.Generic.IList`1[[SignalR.InMemoryMessage`1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]])-> 
    0000000237580080(System.Object[]) 

在我的申請,我保持的客戶名單中ConcurrentDictionary和刪除客戶端對象如下:

Newsfeed.ClientList.TryRemove(fromHubClient.Key, out newsfeedClient); 

我什麼都看不到與wrrong,並看到SignalR.Infrastructure.LockedList 1 [System.Action 1[[System.Collections.Generic.IList 1 [SignalR.InMemoryMessage 1[[System.UInt64, mscorlib]], SignalR]], mscorlib]], mscorlib]], SignalR]

多次提到是否還有與SignalR一些泄漏內存的內存?

回答

1

SignalR 0.5.3中存在內存泄漏。我們目前在1.0 alpha2,所以你可能想要更新使用最新的。