Beamlens.Skill.Allocator (beamlens v0.3.1)

View Source

Memory allocator metrics skill.

Provides callback functions for monitoring VM memory allocator fragmentation and carrier utilization. Detects memory fragmentation issues in long-running nodes where allocated memory exceeds actual usage.

Memory Fragmentation

Long-running BEAM nodes can experience allocator fragmentation where:

  • Memory allocated during peak load is never fully returned to the OS
  • OS reports much higher memory usage than erlang:memory() shows
  • VM allocators (binary_alloc, eheap_alloc, ets_alloc, etc.) fragment carriers

This skill detects such issues by monitoring allocator block and carrier metrics.

All functions are read-only with zero side effects.

Summary

Functions

Detailed metrics for a specific allocator type.

Fragmentation metrics comparing current vs worst-case usage.

Identifies allocators with potential fragmentation issues.

Summary metrics for all VM allocators.

Functions

allocator_by_type(allocator_name)

Detailed metrics for a specific allocator type.

Returns map with carriers, blocks, block_size_mb, carrier_size_mb, and usage_ratio. Returns nil if allocator not found or unavailable.

allocator_fragmentation()

Fragmentation metrics comparing current vs worst-case usage.

Returns map with average_usage_ratio, worst_allocator (name), worst_usage_ratio, and fragmentation_score.

allocator_problematic()

Identifies allocators with potential fragmentation issues.

Returns allocators with usage_ratio < 0.5 (less than 50% carrier utilization). These may indicate memory fragmentation where allocated carriers are underutilized.

allocator_summary()

Summary metrics for all VM allocators.

Returns list of maps with allocator name, carriers, blocks, block size, carrier size, and usage ratio (blocks/carriers).