Every requestor in Pega Platform (web and background) has an associated temporary memory area on the server known as the clipboard. Large clipboards can affect performance because memory in the Java Virtual Machine (JVM) supporting Pega Platform holds the clipboards of all requestors. When the memory consumption of the application increases, more time is spent on garbage collection, which, in turn, increases the response time of the application. Hence, it is important to optimize the size of each user's clipboard.
Development best practices for clipboard optimization
The following list outlines best practices for clipboard optimization.
- Release pages that are no longer needed rather than relying on Pega Platform. Releasing pages for applications that support a high volume of concurrent users reduces the load on the JVM. Pega Platform throws a guardrail warning in activities if the page is not cleaned up. On a periodic basis, verify that pages are released and address any violations. Use the clipboard tool to identify any pages that were automatically passivated but never reactivated. Analyze if those pages are really required and remove them when appropriate. For more information about finding unneeded pages, see "Troubleshooting long-lived clipboard pages."
- Use data pages wherever possible. Data pages can improve performance and reduce memory requirements when all or many requestors in an application need to access information. Additionally, Pega Platform handles the load and removal of the data page based on the scope.
- Ensure that right scope is defined for all the application data pages. An incorrect scope can lead to loading multiple data pages with same content or leaving the data pages in memory for a longer duration than is required
- Limit the number of instances retrieved by the Obj-Browse method, RDB-List method, or a report definition rule by specifying the Max records. Limiting the number of instances reduces the demand for database activity memory.
- When using an Obj-Browse method, consider using lightweight lists, which will have a lighter memory footprint compared to normal clipboard pages. For more information, see "About lightweight lists."
- Retrieve only required properties in an Obj-Browse method, an Obj-List method, or a report definition rule. Verify that the filters load only necessary data to the clipboard. Configuring filters correctly is more efficient than using row visibility conditions to hide rows in a grid.
- Enable the Allow API Query option in Pega Platform 8.4 and later to optimize the performance and memory consumption of data pages, which are sourced from report definitions. For more information, see "Allow API query for data pages."
- Enable the Limit to a single data page option wherever applicable. This option ensures that only one instance of the data page exists on the clipboard at a time, which is useful when search is supported through parameterized data pages.
- Avoid data duplication. During processing, data should exist in only one place.
- Use defer load pattern as applicable. Load data just in time when the end user/process needs it. The following are some examples of this pattern:
- During a call, a customer service representative needs to display customer details instantly. To speed up the initial display of the most relevant data, you can set the deferred load for sections that display secondary information, such as the list of a customer's recent transactions or their dispute history. The secondary content loads only after the web page loads the main content.
- During bulk processing of data, don’t load the entire work object or data instance. Instead, load just the metadata in a list and during the actual processing, load the instance to be updated and clean up the instance after the update. For more information, see "Deferred loading of content."
- When designing background processes, verify that the activity is optimized to reduce the time needed to process a message. Long-running processes are resource intensive. For handling large volumes, consider breaking the batch into multiple chunks. Check the log for the Pega0019 alert to identify long-running requestors. For more information, see "PEGA0019 alert: Long-running requestor detected."
- A single document dynamic container opens only one document at a time, whereas using dynamic container allows for multiple documents to be opened simultaneously. Single-page applications perform better than multi-document applications. Multi-document containers will be deprecated in Cosmos.
Memory-management-related check points
- Verify that the clipboard analysis is handled as part of the development process. Leverage the clipboard tool to analyze the clipboard size of the requestor.
- Use tools such as PLA, PDC, and Log viewer to monitor alert logs for errors related to memory usage:
- PEGA0004 - Quantity of data received by database query exceeds limit
- PEGA0021 - Clipboard memory for declarative pages exceeds limit
- PEGA0028 - GC cannot reclaim memory from memory pools
- PEGA0027 - Number of rows exceeds database list limit
- PEGA0029 - HTML stream size exceeds limit
- PEGA0035 - A Page List property has several elements that exceed a threshold
- For version 8.4 and later Pega Cloud deployments, use the Pega Predictive Diagnostic Cloud to monitor the JVM usage. For more information, see Tools for monitoring system resources in Pega Predictive Diagnostic Cloud.
- Check for memory leaks in the application during development and take relevant actions. For more information, see "Detecting memory leaks in Pega applications."