Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github

LinkedIn

Here’s how to use Redgate ANTS to make C# really sing on NerdDinner

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

This article currently contains notes on using the ANTS profiler for Visual Studio on Windows.

NOTE: Java programmers: please refer to my JVM Profilers page.

Editions and Installers

Red-gate.com has 3 different products for developers, with separate licenses.

There are different pages for each product:

PROTIP: But all download pages download the same file:

DotNETDeveloperBundle.exe, 78.7 MB

NOTE: Many enterprises require you to instead see your system administrator rather than downloading yourself.

14 days trial.

Resources

  • http://documentation.red-gate.com/display/APP7/Worked+example+-+Profiling+an+ASP.NET+application+-+NerdDinner

  • http://documentation.red-gate.com/display/APP7/Setting+up+and+running+a+profiling+session

  • http://documentation.red-gate.com/display/APP7/Working+with+profiling+results

Ben Emmett (@bcemmett) is Regate’s .NET Tools Product Manager (as of 2012).

Configure license

After installation of the app and sample server:

  1. Invoke ANTS Profiler from within Visual Studio:

    ants vs menu 387x194

  2. Set Profiler Settings

    ants 7 4 profiler settings 1078x810

  3. Click Start Profiling.

  1. Click “Stop profiling”.

Sample C# Code

Nerd Diner Sample App

http://nerddinner.com presents a sample .NET MVC app.

The app enables registered users to create, edit, and delete dinners.

The app was written in 2009 by Scott Hanselman, Scott Guthrie, and others at Microsoft.

The app was built to be run locally because its source code is available at
http://nerddinner.codeplex.com (http://tinyurl.com/aspnetmvc). The website describes new features added on August 2011 along with updates for ASP.NET MVC 3.

PROTIP: Use Git to clone the more recent (2016) MVC 5 version on GitHub:

https://github.com/aspnet/NerdDinner

However, other sites have not been updated:

  • http://www.jprl.com/Blog/archive/development/mono/2009/May-14.html Linq to SQL on Mono Update: NerdDinner on Mono - Jonathan Pryor’s web log

  • https://blogs.msdn.microsoft.com/jimoneil/2009/07/27/nerddinner-on-azure-take-2/

The original app version and its source is describe in a free chapter 1 (185 pages) from the O’Reilly book Professional ASP.NET MVC 2.0.

High Level Overview Videos

Memory Leakage as Fast As Possible [4:59] 16 Jun 2015 by Techquickie shows a lot of fun meme photos for computer users (not developers).

Memory Leaks Explained [10:22] 6 Jan 2015 by lcc0612

Heap vs. Stack in .Net C#

.NET Stack and Heap [13:05] 26 Jun 2012 by Wallace Kelly clearly shows C# code and how it stores and moves data in memory.

Memory contains separate stack and heap areas.

Heap contain class instances.

Stack contains local variables.

.NET Stack vs Heap by Gregor Dzierzon

C# Garbage Collection Concepts

https://www.youtube.com/watch?v=-JOkkn1ET8c C# Garbage Collection by Jamie King

https://www.youtube.com/watch?v=cV8YJqc37ww How C# garbage collection works | lynda.com tutorial by LinkedIn Learning Solutions

ANTS

Snapshots

  1. Collect baseline snapshot

    ANTS automatically collects and compares snapshots

  2. Filter

    [6:54] “I’m not going to do what most people do, which is to try to immediately filter out everything that is not their own code”

  3. Look at the one with the largest growth.

  4. Look at the Class List.

  5. For Task Manager, press Ctrl + Shift + Esc

  6. Uncheck “Hide finalizer queue GC roots”

  7. Force a Garbage Collection to clear finalizer queue.

    indrectly

    .tmp temporary files in C:\Documents and Settings...\Local Settings\Temp\Red Gate

ANTS Performance Profiler overview [1:55] 27 Nov 2014 by Redgate

Profiling an ASP.NET Application [3:59] 10 May 2013 by Redgate Videos shows a Windows 10 machine working with the NerdDinner sample app.

profiler ants8 profiling mode 1194x932
(Click to pop-up full-sized image)

Practical Performance Profiling by Redgate Videos

ANTS Memory Profiler 5: How to find a memory leak (1 of 2) [9:12] 15 May 2009 by redgatedotnetteam uses QueryBee app.

“Filtering too early “

ANTS Memory Profiler 5: How to find a memory leak (2 of 2) [8:55] 15 May 2009 by redgatedotnetteam

Expand node that shouldn’t be there.

Click “Show instances of this class on this path”.

Why two instances?

See if “Size with Children” is large.

Show object retention graph.

profiler ants show 862x156

Take another snapshot

ANTS Memory Profiler 5: Filters [5:54] 21 May 2009

https://www.youtube.com/watch?v=y0OZd_JxBrs ANTS Memory Profiler 5: Class Reference Explorer [6:45] by redgatedotnetteam

https://www.youtube.com/watch?v=AaPaIVI-yyI Improve SQL Server performance using profiler and tuning advisor by .NET Interview Preparation videos

Memory profiling a real world application (Part 1) [9:46] 29 Jun 2009 by redgatedotnetteam featuring Alex Davies (developer of ANTS Memory Profiler 5)

Memory profiling a real world application (Part 2) by redgatedotnetteam

https://www.youtube.com/watch?v=FkzyvMlX7vw Performance Tuning .NET & SQL Code using ANTS Profiler with Mitchel Sellers and Redgate LIDNUG LinkedIn

5 minute wonders: Finding lazy loading nasties with ANTS Profiler [4:58] 5 Feb 2013 by Troy Hunt looks at long-running SQL database calls.

5 Misconceptions about .NET Memory Management [52:21] 10 May 2013 by Redgate Videos featuring Clive Tong

  1. A garbage collector collects garbage.

Most young objects die young.

  1. Doing lots of gen0 collections is bad.
  2. Performance counters are great for understanding what is happening.
  3. .NET doesn’t leak memory.
  4. All objects are treated the same.

https://www.youtube.com/watch?v=BRyR5cv6VNg ANTS Memory Profiler 8 by Redgate Videos

Investigating unmanaged memory with ANTS Memory Profiler [6:23] by Redgate Videos

Learning .NET Memory Management (8 VIDEOS) by Redgate Videos

https://www.youtube.com/watch?v=b0tiHyeotRU”> Using .NET Memory Profiler to investigate memory issues</a> by FireflyMigration

https://www.youtube.com/watch?v=lU_YZtvslnI Debugging Memory Leaks Using New NET Memory Diagnostic Tools [5:10] by Microsoft Visual Studio

https://www.youtube.com/watch?v=Tr3vI-BcMdU Finding memory Leaks in .Net Application Ashish Goel

https://www.youtube.com/watch?v=k09bkM3_gsE&list=PLhFdCK734P8AfPwF2HxvcrlnbGv29sKyP 8 VIDEOS Learning .NET Memory Management Redgate Videos

Visual Studio

https://www.youtube.com/watch?v=obU90802hEY Overview of the Performance and Diagnostics Hub in Visual Studio 2013 Microsoft Visual Studio

https://www.youtube.com/watch?v=_e3satbnwHI Using the Diagnostic Tools in Visual Studio 2015 John Koerner

https://www.youtube.com/watch?v=D_AS0KPL1ao Part 8 of C# Tutorial (String, Garbage Collector and CLR Profiler) using Visual Studio GuruWrites

https://www.youtube.com/watch?v=nuF-ToMzDIc 815 1100 Building and Using a Memory Profiler 01 Ricky, Ping-I Chou

Alternatives

https://www.youtube.com/watch?v=g-YW2jkd-Ac How to Use Debug Diagnostic Tool to track Memory leaks Informatica Support

https://www.youtube.com/watch?v=FfpmLFfpSg4 Visual Studio 2010 Profiler compared to dottrace, aqtime, speedtrace pro, ants Dirk8018

Java

https://www.youtube.com/watch?v=we_enrM7TSY Understanding Java Garbage Collection and what you can do about it SpringDeveloper

https://www.youtube.com/watch?v=eu_kTGv61WQ What is memory leak? codebasics 665 views

https://www.youtube.com/watch?v=iFr1cvwhfbw Memory Leak explained with example Software and Testing Training 2,962 views

https://www.youtube.com/watch?v=FLcXf9pO27w From Java Code to Java Heap: Understanding the Memory Usage of Your Application Oracle Learning Library 109,559 views

https://www.youtube.com/watch?v=Dy7WZv5bEV4 Java Memory Leak Detection with JProfiler RuthJ180 49,255 views

https://www.youtube.com/watch?v=8y5Gdd_ImgM Memory Leaks in Java Tech Gig 17,524 views

https://www.youtube.com/watch?v=f2aNWtt0QRo How to Write Memory-Efficient Java Code JavaOne 23,834 views

https://www.youtube.com/watch?v=5joejuE2rEM JVM Heap Dump Analysis - OpenJPA memory leak Pierre-Hugues Charbonneau 22,457 views

Android Java

https://www.youtube.com/watch?v=h7qHsk1nWKI Android Performance Patterns: Performance Cost of Memory Leaks Google Developers 15,400 views

https://www.youtube.com/watch?v=YCC-CpTE2LU “Introduction into Java Profiling” by Fabian Lange - Coding Serbia Conference Coding Serbia Conference 15,263 views