MemoryHealthIndicator

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

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

  // inherited from terminus/lib/HealthIndicator
  protected getStatus(key: string, isHealthy: boolean, data?: { [key: string]: any; }): HealthIndicatorResult
}

Methods

checkHeap()

Checks the heap space and returns the status


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

Parameters

Option Type Description
key string

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> 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: string, rssThreshold: number): Promise<HealthIndicatorResult>

Parameters

Option Type Description
key string

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> The result of the health indicator check

Throws

StorageExceededError In case the rss has exceeded the given threshold