Memory leak when using the Microsoft.SqlServer.Management.Trace.TraceTable object - by Luca Zavarella

Status : 


Sign in
to vote
ID 794965 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 7/25/2013 1:31:51 AM
Access Restriction Public


I'm using Microsoft.SqlServer.Management.Trace.TraceTable object in a loop that cycles a lot of files, in order to store traces data in a table. The script works correctly, but I suppose there is a memory leak somewhere, causing it to consume gigabytes of memory.
Sign in to post a comment.
Posted by alextsln on 2/11/2014 at 10:56 PM
I got the memory leak when using Microsoft.SqlServer.Management.Trace.TraceFile .
After long time reading .trc files, the OutOfMemory exception happened, then the whole program crushed.
I tried to analysis the dump. the !eeheap result is about 100M, but when using !address -summary, the “unclassified” memory is up to 1.8G.
then i made some test code to check out how the problem happened, at last i found 2 point.
1. the Dispose() method of TraceFile is useless. The memory usage will increase by newing intances of the class, and the used memeory cannot be recycle.
2. if i just new one instance of TraceFile class, the memory usage will still increase by executing Read() method, yet the used memeory cannot be recycle.