Everybody thinks about garbage collection the wrong way
.NET MAUI Performance Investigations
New Features in the .NET 9 JIT
namespace MemoryLeakTest; | |
static class MemoryTest | |
{ | |
static readonly List<WeakReference<object>> weakReferences = []; | |
public static int Count => weakReferences.Count; | |
public static void Add(object obj) | |
{ |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<!-- | |
How to define a variable. | |
Just stick a new node in a property group. | |
--> | |
<PropertyGroup> | |
<!-- This node in a property group will define a variable --> | |
<TestVariable>Test Variable Value</TestVariable> | |
new ViewModel().Run(); | |
class ViewModel | |
{ | |
private bool flag = true; | |
public bool Flag {get; set;} = false; | |
public void Run() | |
{ | |
using(new HoldAndChangeValue(ref flag, () => Flag = !Flag)) | |
{ |
using BenchmarkDotNet.Attributes; | |
namespace GeneralBench; | |
public record Registro | |
{ | |
public required string Nome { get; init; } | |
public int Total { get; init; } | |
} | |
[MemoryDiagnoser] |
/* | |
SharpLab tools in Run mode: | |
• value.Inspect() | |
• Inspect.Heap(object) | |
• Inspect.Stack(value) | |
• Inspect.MemoryGraph(value1, value2, …) | |
*/ | |
using System; | |
using System.Threading.Tasks; |
public class GravatarImageSource : ImageSource | |
{ | |
/// <summary>The backing store for the <see cref="Email" /> bindable property.</summary> | |
public static readonly BindableProperty? EmailProperty = BindableProperty.Create(nameof(Email), typeof(string), typeof(GravatarImageSource), defaultValue: GravatarImageSourceDefaults.DefaultEmail, propertyChanged: OnEmailPropertyChanged); | |
/// <summary>The backing store for the <see cref="Image" /> bindable property.</summary> | |
public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(Image), typeof(DefaultImage), typeof(GravatarImageSource), defaultValue: GravatarImageSourceDefaults.Defaultimage, propertyChanged: OnDefaultImagePropertyChanged); | |
/// <summary>Gets or sets the email address.</summary> | |
public string? Email |
class BlaP | |
{ | |
public static async Task<T> FromJsonHttpContent<T>(HttpContent httpContent) | |
{ | |
Stream stream = null; | |
try | |
{ | |
stream = await httpContent.ReadAsStreamAsync(); | |
var res = DeserializeJsonFromsStream<T>(stream); |
static class ComicRouteFactory | |
{ | |
public static RouteFactory Create<TPage, TViewModel>() | |
where TPage : Page, new() | |
where TViewModel : BaseViewModel | |
{ | |
return new Factory<TPage, TViewModel>(); | |
} | |
private class Factory<GPage, GViewModel> : RouteFactory |