MemoryAnalyzers 0.1.0-beta.5

This is a prerelease version of MemoryAnalyzers.
dotnet add package MemoryAnalyzers --version 0.1.0-beta.5                
NuGet\Install-Package MemoryAnalyzers -Version 0.1.0-beta.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MemoryAnalyzers" Version="0.1.0-beta.5">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MemoryAnalyzers --version 0.1.0-beta.5                
#r "nuget: MemoryAnalyzers, 0.1.0-beta.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MemoryAnalyzers as a Cake Addin
#addin nuget:?package=MemoryAnalyzers&version=0.1.0-beta.5&prerelease

// Install MemoryAnalyzers as a Cake Tool
#tool nuget:?package=MemoryAnalyzers&version=0.1.0-beta.5&prerelease                

memory-analyzers

NuGet

A set of Roslyn C# code analyzers for finding memory leaks in iOS and MacCatalyst applications -- with potentially other ideas in the future.

For more information on the "circular reference" problem on Apple platforms, see:

Note that this "circular reference" situation would occur in Swift or Objective-C, so it is not a .NET-specific problem. It does not occur on Android or Windows platforms.

MA0001

Don't define public events in NSObject subclasses:

public class MyView : UIView
{
    // NOPE!
    public event EventHandler MyEvent;
}

Example of MA0001

MA0002

Don't declare members in NSObject subclasses unless they are:

  • WeakReference or WeakReference<T>
  • Value types
class MyView : UIView
{
    // NOPE!
    public UIView? Parent { get; set; }

    public void Add(MyView subview)
    {
        subview.Parent = this;
        AddSubview(subview);
    }
}

Example of MA0002

MA0003

Don't subscribe to events inside NSObject subclasses unless:

  • It's your event via this.MyEvent or from a base type.
  • The method is static.
class MyView : UIView
{
    public MyView()
    {
        var picker = new UIDatePicker();
        AddSubview(picker);
        picker.ValueChanged += OnValueChanged;
    }
    
    void OnValueChanged(object sender, EventArgs e) { }

    // Use this instead and it doesn't leak!
    //static void OnValueChanged(object sender, EventArgs e) { }
}

Example of MA0003

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MemoryAnalyzers:

Package Downloads
Dhgms.QualityAssurancePack

Collection of packages for assisting in QA during .NET software development

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on MemoryAnalyzers:

Repository Stars
dotnet/maui
.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
Redth/Maui.VirtualListView
A slim ListView implementation for .NET MAUI that uses Platform virtualized lists / collections
Version Downloads Last updated
0.1.0-beta.5 15,794 10/30/2023
0.1.0-beta.4 284 10/24/2023
0.1.0-beta.3 4,271 8/10/2023
0.1.0-beta.2 95 8/7/2023
0.1.0-beta.1 110 7/25/2023