# Memory Pinned BOs

reviewed: 15 March 2025

What Are Memory Pinned BOs

You can memory-pin a BO, meaning that each instance is stored in the memory of the worker process once it is loaded from the database. This can increase performance when applied to specific entities.

Scenarios

Memory pinning should be used with care. Entities that are good candidates for memory pinning should adhere to a number of criteria:

  • There should be a small number of records for the entity in the database
  • The data should be static or fairly static

Typical scenarios are:

  • Global settings are stored in a globalSettings entity of which there is only one row and the data is rarely updated
  • Processing is based on profile data, there is a limited number of profiles but the profile data is accessed for nearly all page requests

Static and Dynamic

You make a BO memory pinned by setting the memoryPinMode tag as shown in the following example:

resource main
    <@bo
        label: <@mlText 'Global Settings'>
        table: 'applicationGlobalSettings',
        primaryKey: 'id',
        memoryPinMode: memoryPinMode.Dynamic

There are 3 modes:

Mode Usage
memoryPinMode.None The BO is not memoery pinned, this is the default
memoryPinMode.Dynamic The BO is memory pinned but when used a check is done to see whether the data needs to be reloaded
memoryPinMode.Static The BO is memoery pinned and not reloaded once it has been loaded

How it Works

A BO that is dynamically memory pinned must also be set to auditing.Auditable or auditing.ConcurrencyControl.

When the BO is loaded a timer is set. Whenever the BO is references, CaseMaster will check whether it is 30 seconds or more ago that the BO is last read. If so, CaseMaster will check whether the BO was updated since it was last loaded and re-load it only when required.

This means that a dynamically memory pinned BO will never be more than 30 seconds out of sync with the latest data. Obviously, the performance of a statically memory pinned BO is even better.

The memory pinning happens per worker process. On a server garden (let alone a server farm) each worker process will hold a copy of the memory pinned BO's in memory.

Finally: memory pinning only happens when an instance of the BO is loaded by its' primary key. If you load by any other where clause, the BO's are not memory pinned.

<End of document>