Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is [Cycle Detected] with memory leak?

Visual Studio 2017 Community Edition

I am trying to understand/use the Performance Profiler's Memory Usage in what I feel must be a memory leak in my application (MVVM with custom controls). Three snapshots were taken:

  1. Before opening my suspect user control, NewProgressNoteView.xaml.
  2. At the time of running the user control, and
  3. After exiting the NewProgressNoteView.xaml.

I then compared snapshot #3 to snapshot #1. In the resulting table, I imposed a filter of "NewProgressNoteView". The below is the results of expanding the instance of the top Doctor_Desk.Views.NewProgressNoteView. Of note is '[Cycle Detected]' which feels suspicious, but I do not know what it means exactly or how to use this information to fix the memory leak(s)? What do I do next?

Any help would be most appreciated.

TIA.

enter image description here

like image 499
Alan Wayne Avatar asked Mar 30 '18 04:03

Alan Wayne


People also ask

What causes a memory leak?

A memory leak starts when a program requests a chunk of memory from the operating system for itself and its data. As a program operates, it sometimes needs more memory and makes an additional request.

What is memory leak in IOS?

As per Apple, a memory leak is:Memory that was allocated at some point, but was never released and is no longer referenced by your app. Since there are no references to it, there's now no way to release it and the memory can't be used again.

What is a possible memory leak?

Memory leaks are when programs on the computer incorrectly manage memory allocations. This is not uncommon on modern software and can cause performance drags on the system. The easiest way to fix this issue is to close and reopen the program with the leak, as it will reset the allocations.


1 Answers

What Is [Cycle Detected] when viewing managed memory?

When viewing Heap snapshots inside Visual Studios Diagnostic tools you have:

The Object Type Window which shows objects held in memory.

When you select a particular Object Type, you can access:

  • Paths to Root - Don't be fooled by the fact this information is presented in a tree-view which usually denotes children. Paths to root actually shows Parent objects that reference the object you selected.
  • Referenced Types - Shows the child types referenced by the selected object.

Both these tabs are reference views which help you trace an objects parent and child references presented via an expanding-tree menu.

Cycle Detected simply means that the memory analyzer has found the parent or child reference directly or indirectly references back to your selected object. So rather than display a circular tree-view trace it adds a cycle detected tag.

This isn't neccessarily a bad thing or your root issue.

For further reading about analyzing memory and an expanded explanation of reference views check out this msdn article: https://docs.microsoft.com/en-us/visualstudio/profiling/analyze-memory-usage?view=vs-2019

like image 196
todef96 Avatar answered Oct 02 '22 09:10

todef96