## Overview

Measuring memory usage is crucial for optimizing an application’s performance and ensuring it runs efficiently. By implementing effective memory usage measurement practices, you can enhance user experience, and prevent potential issues related to excessive memory consumption.

## Prerequisites

To measure app memory usage, your website must be in a [**secure context**](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measureUserAgentSpecificMemory#security_requirements).

## Configuration

Coralogix allows you to track the memory usage of your application via the [`measureUserAgentSpecificMemory`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measureUserAgentSpecificMemory) API.

### Automatic

The SDK collects memory usage data every `interval` and sends it to Coralogix.

**Example**

```jsx
CoralogixRum.init({
  // ...
  memoryUsageConfig:{
    enabled:true,
    interval: 300_000 // Defaults to 5 minutes
  }
});
```

### Manual

You can also manually trigger memory usage data collection via `CoralogixRum.measureUserAgentSpecificMemory();`

### Querying memory data

To effectively analyze memory usage, utilize the following attributes in your queries:

- `cx_rum.event_context.type:"memory-usage` - Event type for querying all memory usage events.
- `cx_rum.memory_usage_context.breakdown.types` - Object types that consume the memory (DOM, shared workers, window, etc.).
- `cx_rum.memory_usage_context.breakdown.bytes` - Memory usage for each object type.
- `cx_rum.memory_usage_context.bytes` - Total memory consumption across all objects.

## Support

**Need help?**

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us **via our in-app chat** or by sending us an email to [support@coralogix.com](mailto:support@coralogix.com).
