> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> System table containing information about memory allocations done via jemalloc allocator in different size classes (bins) aggregated from all arenas.

# system.jemalloc_bins

<Info>
  **Querying in ClickHouse Cloud**

  The data in this system table is held locally on each node in ClickHouse Cloud. Obtaining a complete view of all data, therefore, requires the `clusterAllReplicas` function. See [here](/reference/system-tables/overview#system-tables-in-clickhouse-cloud) for further details.
</Info>

<h2 id="description">
  Description
</h2>

Contains information about memory allocations done via jemalloc allocator in different size classes (bins) aggregated from all arenas.
These statistics might not be absolutely accurate because of thread local caching in jemalloc.

<h2 id="columns">
  Columns
</h2>

* `index` ([UInt16](/reference/data-types/index)) — Index of the bin ordered by size.
* `large` ([UInt8](/reference/data-types/index)) — True for large allocations and False for small.
* `size` ([UInt64](/reference/data-types/index)) — Size of allocations in this bin.
* `allocations` ([Int64](/reference/data-types/index)) — Number of allocations.
* `deallocations` ([Int64](/reference/data-types/index)) — Number of deallocations.
* `nregs` ([Int64](/reference/data-types/index)) — Number of regions per slab.
* `curslabs` ([Int64](/reference/data-types/index)) — Current number of slabs.
* `curregs` ([Int64](/reference/data-types/index)) — Current number of regions for this size class.

<h2 id="example">
  Example
</h2>

Find the sizes of allocations that contributed the most to the current overall memory usage.

```sql theme={null}
SELECT
    *,
    allocations - deallocations AS active_allocations,
    size * active_allocations AS allocated_bytes
FROM system.jemalloc_bins
WHERE allocated_bytes > 0
ORDER BY allocated_bytes DESC
LIMIT 10
```

```text theme={null}
┌─index─┬─large─┬─────size─┬─allocactions─┬─deallocations─┬─active_allocations─┬─allocated_bytes─┐
│    82 │     1 │ 50331648 │            1 │             0 │                  1 │        50331648 │
│    10 │     0 │      192 │       512336 │        370710 │             141626 │        27192192 │
│    69 │     1 │  5242880 │            6 │             2 │                  4 │        20971520 │
│     3 │     0 │       48 │     16938224 │      16559484 │             378740 │        18179520 │
│    28 │     0 │     4096 │       122924 │        119142 │               3782 │        15491072 │
│    61 │     1 │  1310720 │        44569 │         44558 │                 11 │        14417920 │
│    39 │     1 │    28672 │         1285 │           913 │                372 │        10665984 │
│     4 │     0 │       64 │      2837225 │       2680568 │             156657 │        10026048 │
│     6 │     0 │       96 │      2617803 │       2531435 │              86368 │         8291328 │
│    36 │     1 │    16384 │        22431 │         21970 │                461 │         7553024 │
└───────┴───────┴──────────┴──────────────┴───────────────┴────────────────────┴─────────────────┘
```
