RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RUNUO] Tools for Memory Leaks analysis

alambik

Sorceror
[RUNUO] Tools for Memory Leaks analysis

Hi all,

I'm not so familiar with C# tools actualy.
What tool can I use to detect the memory leaks of scripts?
How to use it? Any additional compilation option?

I used purify in C++ on unix before, I would like to know if there are similiar tools.

Thank you!
 

Mark

Knight
alambik;710266 said:
Hi all,

I'm not so familiar with C# tools actualy.
What tool can I use to detect the memory leaks of scripts?
How to use it? Any additional compilation option?

I used purify in C++ on unix before, I would like to know if there are similiar tools.

Thank you!

You can use Windows Debugger (windbg) with the son of strike extensions (SOS.dll, comes with .NET).

You can also use the Performance monitor to watch basic statistics about the garbage collector and allocation patterns.

Mono has some built in debugging tools if you are on a Linux system.


EDIT: No special modification of RunUO is neccessary, but windbg must attach or launch the process. Additionally, windbg can be very complex, so use !help frequently. The most useful features are stack traces, watching threads, dumping stack and heap, tracing exceptions, but there are many others.
 

Mark

Knight
Code:
0:000> .load C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\SOS.dll
0:000> !help
-------------------------------------------------------------------------------
SOS is a debugger extension DLL designed to aid in the debugging of managed
programs. Functions are listed by category, then roughly in order of
importance. Shortcut names for popular functions are listed in parenthesis.
Type "!help <functionname>" for detailed info on that function. 

Object Inspection                  Examining code and stacks
-----------------------------      -----------------------------
DumpObj (do)                       Threads
DumpArray (da)                     CLRStack
DumpStackObjects (dso)             IP2MD
DumpHeap                           U
DumpVC                             DumpStack
GCRoot                             EEStack
ObjSize                            GCInfo
FinalizeQueue                      EHInfo
PrintException (pe)                COMState
TraverseHeap                       BPMD 

Examining CLR data structures      Diagnostic Utilities
-----------------------------      -----------------------------
DumpDomain                         VerifyHeap
EEHeap                             DumpLog
Name2EE                            FindAppDomain
SyncBlk                            SaveModule
DumpMT                             GCHandles
DumpClass                          GCHandleLeaks
DumpMD                             VMMap
Token2EE                           VMStat
EEVersion                          ProcInfo 
DumpModule                         StopOnException (soe)
ThreadPool                         MinidumpMode 
DumpAssembly                       
DumpMethodSig                      Other
DumpRuntimeTypes                   -----------------------------
DumpSig                            FAQ
RCWCleanupList
DumpIL
 

Mark

Knight
Some sample output from a fresh RunUO build:

Code:
0:003> !dumpheap -stat
total 7739 objects
Statistics:
      MT    Count    TotalSize Class Name
7912ae18        1           12 System.Collections.Generic.ObjectEqualityComparer`1[[System.Reflection.Assembly, mscorlib]]
790ff624        1           12 System.Text.DecoderExceptionFallback
790ff5d8        1           12 System.Text.EncoderExceptionFallback
790f6b64        1           12 System.EventArgs
009b2428        1           12 System.ConsoleColor[]
00995cc8        1           12 Server.Timer+TimerThread
7910e8dc        1           16 System.Globalization.GlobalizationAssembly
7910cfc0        1           16 System.Runtime.InteropServices.HandleRef
00d55cc4        1           16 Server.Point3DList
7911b718        1           20 System.Threading.ThreadHelper
7910e284        1           20 System.Random
7910c800        1           20 System.Security.PermissionToken
790ff140        1           20 Microsoft.Win32.SafeHandles.SafeFileMappingHandle
790ff0e4        1           20 Microsoft.Win32.SafeHandles.SafeViewOfFileHandle
790fe0b0        1           20 System.Text.InternalEncoderBestFitFallback
790fcd7c        1           20 Microsoft.Win32.SafeHandles.SafeFileHandle
79128ff4        1           24 System.Collections.Generic.List`1[[System.Reflection.Assembly, mscorlib]]
790fe108        1           24 System.Text.InternalDecoderBestFitFallback
790fcba0        2           24 System.Security.Permissions.SecurityPermission
790fc3f4        1           24 System.OperatingSystem
790fc32c        1           24 System.Version
00d57554        1           24 System.Collections.Generic.Stack`1[[System.ConsoleColor, mscorlib]]
009b2050        1           24 System.Collections.Generic.List`1[[System.IO.TextWriter, mscorlib]]
009970b0        1           24 System.Collections.Generic.List`1[[Server.Map, RunUO]]
00994e6c        1           24 Server.MultiTextWriter
790ff714        1           28 System.Text.EncoderNLS
790ff3f8        1           28 System.Text.UTF8Encoding
790fd2f4        1           28 System.IO.Stream+NullStream
790fccd8        1           28 Microsoft.Win32.Win32Native+InputRecord
790fa4a4        1           28 System.SharedStatics
7911bc7c        1           32 System.UnhandledExceptionEventHandler
7910e9a0        1           32 System.Globalization.CompareInfo
7910c924        1           32 System.Security.PermissionTokenFactory
7910c0f4        1           32 System.EventHandler
79101aac        1           32 System.Runtime.CompilerServices.RuntimeHelpers+CleanupCode
79101988        1           32 System.Runtime.CompilerServices.RuntimeHelpers+TryCode
790ff684        1           32 System.Text.UTF8Encoding+UTF8Encoder
0099502c        1           32 Server.Core+ConsoleEventHandler
79122868        1           36 System.Int64[]
7911cf80        1           36 System.IO.BinaryWriter
7910c88c        1           36 System.Security.Util.TokenBasedSet
791074a8        1           36 System.Collections.Queue
790fd0c4        1           36 System.IO.__ConsoleStream
7910ba78        2           40 Microsoft.Win32.SafeHandles.SafeWaitHandle
790fab38        1           40 System.AppDomainSetup
7911b4f0        1           44 System.Collections.Queue+SynchronizedQueue
7910b830        2           48 System.Threading.AutoResetEvent
79104b50        3           48 System.DateTime
790ff814        2           48 System.IO.TextWriter+SyncTextWriter
790fb5d8        2           48 System.Reflection.Assembly
00d579b8        1           52 System.Collections.Generic.Dictionary`2[[System.Reflection.Assembly, mscorlib],[Server.TypeCache, RunUO]]
790ff21c        1           56 System.IO.StreamWriter
790fe94c        3           60 System.Globalization.CultureTableItem
790fdb60        5           60 System.Int32
7911b624        2           64 System.Threading.ThreadStart
7910b5d8        4           64 System.TimeSpan
790fe854        1           68 System.Globalization.CultureTable
790fc664        2           72 System.Security.PermissionSet
790f9ad4        1           72 System.ExecutionEngineException
790f9a30        1           72 System.StackOverflowException
790f998c        1           72 System.OutOfMemoryException
7912ef54        1           76 System.TimeSpan[]
7912ee9c        1           76 System.DateTime[]
790fdf7c        1           76 System.Text.SBCSCodePageEncoding
79106368        2           96 System.Reflection.Module
790fa704        1          100 System.AppDomain
790fa000        2          104 System.Threading.Thread
00d55e18        2          120 Server.Point3D[]
790fe4f8        3          144 System.Globalization.CultureTableRecord
790f9b78        2          144 System.Threading.ThreadAbortException
7a74ec00        1          160 System.Diagnostics.Process
790f8a7c       14          168 System.Object
00d55980        8          192 System.Collections.Generic.List`1[[Server.Timer, RunUO]]
790fe2e4        3          204 System.Globalization.CultureInfo
790fec90        2          256 System.Globalization.NumberFormatInfo
790fb144       13          260 System.RuntimeType
00d572dc        3          312 Server.SkillName[]
7912677c        1          412 System.Single[]
79122414        8          444 System.Int32[]
7912273c        4          580 System.Byte[]
79115cb0       29          580 Microsoft.Win32.SafeHandles.SafeFindHandle
79110188       37          592 System.Security.Permissions.FileIOAccess
790fd8b4       11          616 System.Collections.Hashtable
79115c04       32          640 System.IO.Directory+SearchData
79129130       32          768 System.Collections.Generic.List`1[[System.IO.Directory+SearchData, mscorlib]]
791293b4       33          792 System.Collections.Generic.List`1[[System.String, mscorlib]]
7910ddd4       37          888 System.Security.Util.StringExpressionSet
79110070       37         1332 System.Security.Permissions.FileIOPermission
79122610       11         1584 System.Collections.Hashtable+bucket[]
79122994       70         1688 System.Char[]
790fad38      147         1764 System.Char
7910234c       74         1776 System.Collections.ArrayList
79115b50       33         1980 Microsoft.Win32.Win32Native+WIN32_FIND_DATA
7912254c      348        35996 System.Object[]
00150ed0       11       184080      Free
790f9244     6646       491248 System.String
Total 7739 objects
 
Top