> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-parallel-read-in-order-multi-part.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.

For small size classes the slab columns (`slab_size`, `nonfull_slabs` and the `waste` alias) measure memory lost to slab fragmentation.

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

* `index` ([UInt16](/reference/data-types/int-uint)) — Index of the bin ordered by size.
* `large` ([UInt8](/reference/data-types/int-uint)) — True for large allocations and False for small.
* `size` ([UInt64](/reference/data-types/int-uint)) — Size of allocations in this bin.
* `allocations` ([Int64](/reference/data-types/int-uint)) — Number of allocations.
* `deallocations` ([Int64](/reference/data-types/int-uint)) — Number of deallocations.
* `nregs` ([Int64](/reference/data-types/int-uint)) — Number of regions per slab.
* `curslabs` ([Int64](/reference/data-types/int-uint)) — Current number of slabs.
* `curregs` ([Int64](/reference/data-types/int-uint)) — Current number of regions for this size class.
* `slab_size` ([UInt64](/reference/data-types/int-uint)) — Size of each slab in bytes. Zero for large size classes, which are not slab-based.
* `nonfull_slabs` ([Int64](/reference/data-types/int-uint)) — Current number of slabs that contain at least one free region. Zero for large size classes.

**Aliases:**

* `availregs` — Alias for `nregs * curslabs`.
* `util` — Alias for `curregs / availregs`.
* `waste` — Alias for `greatest((curslabs * slab_size) - (curregs * size), 0)`.

<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 │
└───────┴───────┴──────────┴──────────────┴───────────────┴────────────────────┴─────────────────┘
```
