---
type: api
title: Get machine learning memory usage info
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-get-memory-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-get-memory-stats
products:
  - Elasticsearch
---

# Get machine learning memory usage info


Availability: 8.2+

## Paths

- `GET` `/_ml/memory/{node_id}/_stats`
- `GET` `/_ml/memory/_stats`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#bearerauth)

#### Path Parameters

- `node_id` (string Id) — optional, leave it out to use `/_ml/memory/_stats`
  The names of particular nodes in the cluster to target. For example, `nodeId1,nodeId2` or
`ml:true`

## Description

Get information about how machine learning jobs and trained models are using memory,
on each node, both within the JVM heap, and natively, outside of the JVM.

## Required authorization

* Cluster privileges: `monitor_ml`

## Query String Parameters

- `master_timeout` (string Duration · default: 30s)
  Period to wait for a connection to the master node. If no response is received before the timeout
expires, the request fails and returns an error.
- `timeout` (string Duration · default: 30s)
  Period to wait for a response. If no response is received before the timeout expires, the request
fails and returns an error.

## Response

`application/json`

- `_nodes` ({} NodeStatistics)
  - `failures` ([] ErrorCause)
    - `type` (string)
      The type of error
    - `reason` (union string) — nullable
      A human-readable explanation of the error, in English.
      One of: `string`
    - `stack_trace` (string)
      The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
    - `caused_by` ({} ErrorCause) — recursive
      Same fields as `failures` in `_nodes`
    - `root_cause` ([] ErrorCause) — recursive
      Same fields as `failures` in `_nodes`
    - `suppressed` ([] ErrorCause) — recursive
      Same fields as `failures` in `_nodes`
  - `total` (number)
    Total number of nodes selected by the request.
  - `successful` (number)
    Number of nodes that responded successfully to the request.
  - `failed` (number)
    Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or failure is included in the response.
- `cluster_name` (string Name)
- `nodes` (map string to Memory)
  Map values ({} Memory)
  - `attributes` (map string to string)
  - `jvm` ({} JvmStats)
    Contains Java Virtual Machine (JVM) statistics for the node.
    - `heap_max` (number | string ByteSize)
      Maximum amount of memory available for use by the heap.
    - `heap_max_in_bytes` (number)
      Maximum amount of memory, in bytes, available for use by the heap.
    - `java_inference` (number | string ByteSize)
      Amount of Java heap currently being used for caching inference models.
    - `java_inference_in_bytes` (number)
      Amount of Java heap, in bytes, currently being used for caching inference models.
    - `java_inference_max` (number | string ByteSize)
      Maximum amount of Java heap to be used for caching inference models.
    - `java_inference_max_in_bytes` (number)
      Maximum amount of Java heap, in bytes, to be used for caching inference models.
  - `mem` ({} MemStats)
    Contains statistics about memory usage for the node.
    - `adjusted_total` (number | string ByteSize)
      If the amount of physical memory has been overridden using the es.total_memory_bytes system property
then this reports the overridden value. Otherwise it reports the same value as total.
    - `adjusted_total_in_bytes` (number)
      If the amount of physical memory has been overridden using the `es.total_memory_bytes` system property
then this reports the overridden value in bytes. Otherwise it reports the same value as `total_in_bytes`.
    - `total` (number | string ByteSize)
      Total amount of physical memory.
    - `total_in_bytes` (number)
      Total amount of physical memory in bytes.
    - `ml` ({} MemMlStats)
      Contains statistics about machine learning use of native memory on the node.
      - `anomaly_detectors` (number | string ByteSize)
        Amount of native memory set aside for anomaly detection jobs.
      - `anomaly_detectors_in_bytes` (number)
        Amount of native memory, in bytes, set aside for anomaly detection jobs.
      - `data_frame_analytics` (number | string ByteSize)
        Amount of native memory set aside for data frame analytics jobs.
      - `data_frame_analytics_in_bytes` (number)
        Amount of native memory, in bytes, set aside for data frame analytics jobs.
      - `max` (number | string ByteSize)
        Maximum amount of native memory (separate to the JVM heap) that may be used by machine learning native processes.
      - `max_in_bytes` (number)
        Maximum amount of native memory (separate to the JVM heap), in bytes, that may be used by machine learning native processes.
      - `native_code_overhead` (number | string ByteSize)
        Amount of native memory set aside for loading machine learning native code shared libraries.
      - `native_code_overhead_in_bytes` (number)
        Amount of native memory, in bytes, set aside for loading machine learning native code shared libraries.
      - `native_inference` (number | string ByteSize)
        Amount of native memory set aside for trained models that have a PyTorch model_type.
      - `native_inference_in_bytes` (number)
        Amount of native memory, in bytes, set aside for trained models that have a PyTorch model_type.
  - `name` (string Name)
    Human-readable identifier for the node. Based on the Node name setting setting.
  - `roles` ([] string)
    Roles assigned to the node.
  - `transport_address` (string)
    The host and port where transport HTTP connections are accepted.
  - `ephemeral_id` (string Id)
## Code Examples

#### Console

```console
GET _ml/memory/_stats?human
```

#### JavaScript

```javascript
const response = await client.ml.getMemoryStats({
  human: "true",
});
```

#### Python

```python
resp = client.ml.get_memory_stats(
    human=True,
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_ml/memory/_stats?human" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().getMemoryStats(g -> g);
```

#### C#

```c#
var response = await client.MachineLearning.GetMemoryStatsAsync();
```

#### PHP

```php
$resp = $client->ml()->getMemoryStats([
    "human" => "true",
]);
```

#### Ruby

```ruby
response = client.ml.get_memory_stats(
  human: "true"
)
```

