Skip to main content

GRAPH.MEMORY

The GRAPH.MEMORY command returns detailed memory consumption statistics for a specific graph in megabytes (MB). It provides insight into how much memory is used by various internal data structures such as nodes, edges, schemas, indices, and matrix representations. This command can be used to monitor memory consumption at the graph level, making it especially useful for debugging, monitoring, performance optimization, and capacity planning in FalkorDB deployments.

Syntax

GRAPH.MEMORY USAGE <graph-name> [SAMPLES <count>]

Usage: GRAPH.MEMORY USAGE <graph_id> [SAMPLES <count>]

Arguments

ArgumentDescription
<graph-name>The name of the graph to inspect (also referred to as <graph_id>).
SAMPLES <n>(Optional) Number of samples to take when estimating memory usage. A higher number improves accuracy but increases computation time. The samples are averaged to estimate the total size. By default, this option is set to 100 if not specified.

Return

The command returns an array of key-value pairs, where each pair represents a specific memory metric and its value (in MB), corresponding to different components of the graph:

Metric Name / FieldTypeDescription
total_graph_sz_mbintegerTotal memory consumed by the graph.
label_matrices_sz_mbintegerAmount of memory used by label matrices (node labels tracking).
relation_matrices_sz_mbintegerAmount of memory used by relationship type matrices (graph topology tracking).
amortized_node_block_sz_mbintegerMemory used by nodes (amortized node storage).
amortized_node_storage_sz_mbintegerAmount of memory used for nodes storage (alternative naming).
amortized_node_attributes_by_label_sz_mbintegerMemory used by node attributes, split by node label.
amortized_unlabeled_nodes_attributes_sz_mbintegerMemory used by node attributes with no label.
amortized_edge_block_sz_mbintegerMemory used by edges (amortized edge storage).
amortized_edge_storage_sz_mbintegerAmount of memory used for relationships storage (alternative naming).
amortized_edge_attributes_by_type_sz_mbintegerMemory used by edge attributes, split by relationship type.
indices_sz_mbintegerAmount of memory consumed by indices (if any).

Note: Metrics like amortized_node_block_sz_mb and amortized_node_storage_sz_mb are alternative names for the same data; both are included for clarity.

Examples

Basic Usage

import { FalkorDB } from 'falkordb';
const db = await FalkorDB.connect({
socket: { host: 'localhost', port: 6379 }
});
const graph = db.selectGraph('myGraph');
const memoryInfo = await graph.memoryUsage();
console.log(memoryInfo);

With Sampling

const memoryInfo = await graph.memoryUsage({ samples: 500 });
console.log(memoryInfo);

Sample Output

127.0.0.1:6379> GRAPH.MEMORY USAGE flights
1) "total_graph_sz_mb"
2) (integer) 1086
3) "label_matrices_sz_mb"
4) (integer) 96
5) "relation_matrices_sz_mb"
6) (integer) 64
7) "amortized_node_storage_sz_mb"
8) (integer) 120
9) "amortized_edge_storage_sz_mb"
10) (integer) 54
11) "indices_sz_mb"
12) (integer) 752