{"id":17950845,"url":"https://github.com/jonathanpeppers/memory-analyzers","last_synced_at":"2025-07-18T00:08:01.452Z","repository":{"id":182354789,"uuid":"667901590","full_name":"jonathanpeppers/memory-analyzers","owner":"jonathanpeppers","description":"C# code analyzers for finding memory leaks","archived":false,"fork":false,"pushed_at":"2023-10-30T19:14:48.000Z","size":530,"stargazers_count":43,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T23:51:07.388Z","etag":null,"topics":["catalyst","dotnet","hacktoberfest","ios","maui","memory-leak"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanpeppers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-18T14:56:17.000Z","updated_at":"2025-01-15T21:40:50.000Z","dependencies_parsed_at":"2024-10-29T10:03:53.390Z","dependency_job_id":null,"html_url":"https://github.com/jonathanpeppers/memory-analyzers","commit_stats":null,"previous_names":["jonathanpeppers/memory-analyzers"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jonathanpeppers/memory-analyzers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanpeppers%2Fmemory-analyzers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanpeppers%2Fmemory-analyzers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanpeppers%2Fmemory-analyzers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanpeppers%2Fmemory-analyzers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanpeppers","download_url":"https://codeload.github.com/jonathanpeppers/memory-analyzers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanpeppers%2Fmemory-analyzers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265683369,"owners_count":23810837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["catalyst","dotnet","hacktoberfest","ios","maui","memory-leak"],"created_at":"2024-10-29T09:40:44.854Z","updated_at":"2025-07-18T00:08:01.127Z","avatar_url":"https://github.com/jonathanpeppers.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memory-analyzers\n\n [![NuGet](https://buildstats.info/nuget/MemoryAnalyzers?includePreReleases=true)](https://www.nuget.org/packages/MemoryAnalyzers/)\n\nA set of Roslyn C# code analyzers for finding memory leaks in iOS and\nMacCatalyst applications -- with potentially other ideas in the future.\n\nFor more information on the \"circular reference\" problem on Apple platforms,\nsee:\n\n* https://github.com/dotnet/maui/wiki/Memory-Leaks#circular-references-on-ios-and-catalyst\n\nNote that this \"circular reference\" situation would occur in Swift or\nObjective-C, so it is not a .NET-specific problem. It does not occur on Android\nor Windows platforms.\n\n## MA0001\n\nDon't define `public` events in `NSObject` subclasses:\n\n```csharp\npublic class MyView : UIView\n{\n    // NOPE!\n    public event EventHandler MyEvent;\n}\n```\n\n![Example of MA0001](docs/images/MA0001.png)\n\n## MA0002\n\nDon't declare members in `NSObject` subclasses unless they are:\n\n* `WeakReference` or `WeakReference\u003cT\u003e`\n* Value types\n\n```csharp\nclass MyView : UIView\n{\n    // NOPE!\n    public UIView? Parent { get; set; }\n\n    public void Add(MyView subview)\n    {\n        subview.Parent = this;\n        AddSubview(subview);\n    }\n}\n```\n\n![Example of MA0002](docs/images/MA0002.png)\n\n## MA0003\n\nDon't subscribe to events inside `NSObject` subclasses unless:\n\n* It's your event via `this.MyEvent` or from a base type.\n* The method is `static`.\n\n```csharp\nclass MyView : UIView\n{\n    public MyView()\n    {\n        var picker = new UIDatePicker();\n        AddSubview(picker);\n        picker.ValueChanged += OnValueChanged;\n    }\n    \n    void OnValueChanged(object sender, EventArgs e) { }\n\n    // Use this instead and it doesn't leak!\n    //static void OnValueChanged(object sender, EventArgs e) { }\n}\n```\n\n![Example of MA0003](docs/images/MA0003.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanpeppers%2Fmemory-analyzers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanpeppers%2Fmemory-analyzers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanpeppers%2Fmemory-analyzers/lists"}