KB0050 - High memory usage for apps\dashboards using UDElement event handlers

KB0050 - High memory usage for apps\dashboards using UDElement event handlers

Affected Versions

- PowerShell Universal 4.1.1 and earlier
- PowerShell Universal 3.9.17 and earlier

Problem

PowerShell Universal apps (v4) and dashboards (v3) will consume gradually more memory when being accessed by users when the dashboard is using a New-UDElement event handler. 
  1. New-UDElement -Tag 'div' -Content {} -Attributes @{
  2.      onClick = {}
  3. }

Root Cause

PowerShell Universal is incorrectly registering the event handlers in a way that prevents them from being removed automatically causing them to grow indefinitely. 

Work Around 1

Restarting the PowerShell Universal app or dashboard will clear the registered event handlers and begin to release memory. Note that memory will be released gradually over time due to .NET garbage collection. 

Work Around 2

Avoid the use of New-UDElement event handlers. Consider using alternative components. For example, New-UDLink with the -Content parameter can replace the usage of OnClick.
    • Related Articles

    • KB0044 - High memory usage in a long running, complex App

      Problem Memory usage can grow continuously in a complex app that is either long running and\or very busy. Root Cause Apps maintain user state as the users interact with the app. This state includes variables that are set and event handlers that are ...
    • KB0012 - High Availability

      Update Please see the documentation at https://docs.powershelluniversal.com/config/hosting/high-availability for in-depth details on this topic. Below is an overview statement from Adam Driscoll on this topic as well. Adam's statement Our high ...
    • KB0058 - PowerShell Universal Browser Times Out Before Session Timeout When Using OIDC

      Affected Versions - All Support Versions Problem Setting the session timeout in appsettings.json does not have an affect on how soon the user is logged out from their session. Root Cause When using OpenID Connect, the -UseTokenLifetime parameter ...
    • KB0046 - Collecting a Memory Dump

      Purpose The purpose of this document is to provide steps for collecting a memory dump. Occasionally, Ironman Software support may request a memory dump of one or more of the processes involved with the functioning of our software. These memory dumps ...
    • KB0068 - Group Membership Claims are Missing when using OpenID Connect (OIDC) and Azure Entra ID (Azure AD)

      Scope This issue affects users wishing to retreive group membership claims from Azure Entra ID (formerly, Azure Active Directory) using OpenID Connect (OIDC) authentication. Problem Not group membership claims are available within Apps while using ...