MemoryHealthIndicator

The MemoryHealthIndicator contains checks which are related to the memory storage of the current running machine

  
class MemoryHealthIndicator {
  checkHeap<Key extends string = string>(key: Key, heapUsedThreshold: number): Promise<HealthIndicatorResult<Key>>
  checkRSS<Key extends string = string>(key: Key, rssThreshold: number): Promise<HealthIndicatorResult<Key>>
}

Methods

checkHeap()

Checks the heap space and returns the status


checkHeap<Key extends string = string>(key: Key, heapUsedThreshold: number): Promise<HealthIndicatorResult<Key>>

Parameters

Option Type Description
key Key

The key which will be used for the result object

heapUsedThreshold number

Examples

    
// The process should not use more than 150MB memory
memoryHealthIndicator.checkHeap('memory_heap', 150 * 1024 * 1024);

Returns

Promise<HealthIndicatorResult<Key>> The result of the health indicator check

Throws

StorageExceededError In case the heap has exceeded the given threshold

checkRSS()

Checks the rss space and returns the status


checkRSS<Key extends string = string>(key: Key, rssThreshold: number): Promise<HealthIndicatorResult<Key>>

Parameters

Option Type Description
key Key

The key which will be used for the result object

rssThreshold number

Examples

    
// The process should not have more than 150MB allocated
memoryHealthIndicator.checkRSS('memory_rss', 150 * 1024 * 1024);

Returns

Promise<HealthIndicatorResult<Key>> The result of the health indicator check

Throws

StorageExceededError In case the rss has exceeded the given threshold