Below I have attached my blazor code.
private delegate Task keyActionDelegate(KeyboardEventArgs e);
private KeyActionDelegate _keyActionDelegate;
protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
_keyActionDelegate = new KeyActionDelegate(keyActionHandler);
Attributes = BaseUtils.UpdateDictionary("onkeydown", _keyActionDelegate, Attributes);
}
internal async override void ComponentDispose()
{
base.ComponentDispose();
_keyActionDelegate = null;
}
A memory leak has occurred due to keyActionDelegate.
I have tried setting the null value to the _keyActionDelegate variable in the ComponentDispose() method, but still a memory leak has occurred. Is there any other way to avoid memory leaks?