Developer technologies | .NET | .NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
Does this code in MAUI app in net 9 can lead to leak memory if not using it , if yes why ?
Thanks,
public MyRootPage() // ctor
{
#if WINDOWS
System.Diagnostics.PerformanceCounter _ramCounter;
```#endif
#if WINDOWS
```sql
_ramCounter = new System.Diagnostics.PerformanceCounter("Memory", "Available MBytes");
```#endif
}
maybe. it won't release its resources until you call .Close() or .Dispose(). as Maui windows don't have a .Dispose event, this is difficult to code correctly. a better option would be to inject a singleton.