Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#232 closed Bug (fixed)

Distributed KeySearcher OutOfMemoryException

Reported by: Sven Rech Owned by: schwittmann
Priority: Important Milestone: CrypTool 2.0 BETA 4
Component: General Keywords:
Cc: krueger, schwittmann

Description (last modified by Sven Rech)

After a very long time of calculating, the following exception will be thrown:

System.OutOfMemoryException was unhandled
  Message=Exception of type 'System.OutOfMemoryException' was thrown.
  Source=PresentationCore
  StackTrace:
       at System.Windows.Media.ByteStreamGeometryContext.ShrinkToFit()
       at System.Windows.Media.ByteStreamGeometryContext.DisposeCore()
       at System.Windows.Media.StreamGeometryContext.System.IDisposable.Dispose()
       at System.Windows.Media.ByteStreamGeometryContext.Close()
       at System.Windows.Media.PathGeometry.GetPathGeometryData()
       at System.Windows.Media.PathGeometry.InternalCombine(Geometry geometry1, Geometry geometry2, GeometryCombineMode mode, Transform transform, Double tolerance, ToleranceType type)
       at System.Windows.Media.CombinedGeometry.GetAsPathGeometry()
       at System.Windows.Media.CombinedGeometry.GetBoundsInternal(Pen pen, Matrix matrix, Double tolerance, ToleranceType type)
       at System.Windows.Media.BoundsDrawingContextWalker.PushClip(Geometry clipGeometry)
       at System.Windows.Media.RenderData.DrawingContextWalk(DrawingContextWalker ctx)
       at System.Windows.Media.RenderData.GetContentBounds(BoundsDrawingContextWalker ctx)
       at System.Windows.UIElement.GetHitTestBounds()
       at System.Windows.Media.Visual.PrecomputeContent()
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.PrecomputeRecursive(Rect& bboxSubgraph)
       at System.Windows.Media.Visual.Precompute()
       at System.Windows.Media.CompositionTarget.System.Windows.Media.ICompositionTarget.Render(Boolean inResize, Channel channel)
       at System.Windows.Media.MediaContext.Render(ICompositionTarget resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at CrypStartup.App.Main() in C:\Users\Public\Documents\ct2svn\trunk\CrypStartup\obj\x86\Release\App.g.cs:line 0
  InnerException: 

Attachments (6)

instance_list.png (200.2 KB) - added by Matthäus Wander 11 years ago.
mfbdclient_chain1.png (183.8 KB) - added by Matthäus Wander 11 years ago.
mfbdclient_chain2.png (203.7 KB) - added by Matthäus Wander 11 years ago.
webdht_chain.png (245.5 KB) - added by Matthäus Wander 11 years ago.
fullmesh_instances.png (184.6 KB) - added by Matthäus Wander 11 years ago.
fullmesh_chain.png (215.4 KB) - added by Matthäus Wander 11 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 11 years ago by Sven Rech

Description: modified (diff)

comment:2 Changed 11 years ago by Sven Rech

After further investigation, I found out, that the increasing usage of memory happens when reconnecting. So just pull your network cable and see the memory usage grow.

By using "JetBrains dotTrace Memory", I found out, that increasing demand of memory comes from byte[] objects. Unfortunately, the programm can't tell me which part of the code allocates them, but I would bet on P@P.

Changed 11 years ago by Matthäus Wander

Attachment: instance_list.png added

Changed 11 years ago by Matthäus Wander

Attachment: mfbdclient_chain1.png added

Changed 11 years ago by Matthäus Wander

Attachment: mfbdclient_chain2.png added

comment:3 Changed 11 years ago by Matthäus Wander

I reproduced the error by starting CT2, disconnecting the networking, then clicking play in the p2p keysearcher sample.

The results are shown in the attached images:

  • each reconnection attempt results in a new instance of Snal, MFBDClient and WebDHT
  • with each reconnection attempt the chain of references grows: WebDHT.oldSSLCallback -> RemoteCertificateValidationCallback -> WebDHT ... and so on

comment:4 Changed 11 years ago by Sven Rech

By the way: The error also occurs without the KeySearcher: Start Cryptool, connect to network, pull your network cable and see what happens.

@Theo: Can you acknowledge by using your debugging tools that this is exactly the same error as the one you encountered when starting the KeySearcher?

Changed 11 years ago by Matthäus Wander

Attachment: webdht_chain.png added

comment:5 Changed 11 years ago by Matthäus Wander

Cc: krueger schwittmann added

@Sven: Yes, memory leak occurs even without any KeySearcher instance.

See attached webdht_chain.png: the problem seems to be a circular reference of the oldSSLCallback field in WebDHT.

comment:6 Changed 11 years ago by schwittmann

Working on it.

BTW: Couldn't assign ticket to myself due to lack of permissions.

Changed 11 years ago by Matthäus Wander

Attachment: fullmesh_instances.png added

comment:7 Changed 11 years ago by Matthäus Wander

Owner: changed from Sven Rech to schwittmann
Status: newassigned

There seem to be two different memory leaks:

  1. The WebDHT circular reference as explained above.
  2. Another leak occuring also (or only) in FullMesh. See attached fullmesh_instances.png and fullmesh_chain.png: There is no circular reference in FullMesh, but still there is a bunch of instances not being removed.

@Lorenz: I've just granted trac developer permissions to you.

comment:8 Changed 11 years ago by schwittmann

Status: assignedaccepted

Please test again with p@p r6599, at least the webdht bug should be fixed there.

Changed 11 years ago by Matthäus Wander

Attachment: fullmesh_chain.png added

comment:9 Changed 11 years ago by Matthäus Wander

Resolution: fixed
Status: acceptedclosed

(In [2976]) Thanks, that did it. WebDHT memory leak has been fixed by Lorenz in pap 6599, closes #232.

The other (unrelated) problem with FullMesh still exists, but as we don't use it in CT2 currently, we can consider this particular CT2 ticket to be fixed.

comment:10 Changed 11 years ago by Matthäus Wander

(In [2982]) new pap rev 6602 fixing an interval bug that lead to memory leaks in FullMeshOverlay (see #232)

Note: See TracTickets for help on using tickets.