Memory Leaks Diagnostic Service

Memory Leaks Diagnostic Service is intended to diagnose memory leaks associated with the use of ObjectSpace. It is in demand in testing of application solutions.

To activate the service, initialize it by calling the Initialize() method. The initialization can be performed, for example, in the Setup(XafApplication) method of the  platform-independent module:

  • c#
  • VB

public sealed partial class NorthwindDCModule : ModuleBase
  public override void Setup(XafApplication application)
    application.SetupComplete += (sender, args) =>

Public Partial NotInheritable Class NorthwindDCModule
  Inherits ModuleBase
  Public Overrides Sub Setup(ByVal application As XafApplication)
    application.SetupComplete += Sub(ByVal sender, ByVal args)
    End Sub
  End Sub
End Class

If diagnostics service is active, the Tools menu contains the Memory Leaks Info item.


This item displays a list of all objects in ObjectSpace and UnitOfWork which are not disposed at the moment:


Double click on the record shows detailed information about the not disposed object, including the call stack, which allows you to figure out which component created the object:


See also Xafari Service.