Peak Retained Memory and Total Allocation

Peak retention concerns how much memory stays live at once. Total allocation can grow through objects that are quickly discarded.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace repeated buffers
  2. Use both observations as needed
  3. Compare turnover with simultaneously retained data
  4. Use a metric that observes the suspected problem

Trace repeated buffers

Allocating and releasing ten buffers one by one can allocate ten buffers over the run while keeping about one such buffer live at a time. See temporary space and lifetime.

Use both observations as needed

Frequent allocation can cost time even at a modest peak. A memory limit cares about peak usage under the measured workload. Collection sizes describe what can be retained.[1]

Compare turnover with simultaneously retained data

A loop allocates a one-megabyte buffer on each of one hundred iterations and releases each before the next. It allocates a hundred megabytes over the run but needs only about one megabyte simultaneously for that buffer purpose. See temporary storage by lifetime.

Allocate and release 1 MB, repeated 100 times
Total allocated by these requests: 100 MB
Peak simultaneously owned by these requests: about 1 MB

Use a metric that observes the suspected problem

An allocator can keep released pages for reuse, so process RSS need not drop immediately. Churn can still consume CPU. Record both retained and allocated measurements under the same workload.

References

  1. Google, Site Reliability Engineering ↩