Raxol.Terminal.Buffer.MemoryManager (Raxol v0.5.0)

View Source

Handles calculation and checking of terminal buffer memory usage.

Summary

Functions

Calculates the approximate memory usage of a single screen buffer.

Estimates the approximate memory usage for a given set of dimensions.

Calculates the total approximate memory usage for two buffers (active and back).

Checks if the given memory usage is within the specified limit.

Trims the scrollback buffer to the specified limit.

Functions

calculate_buffer_usage(buffer)

@spec calculate_buffer_usage(Raxol.Terminal.ScreenBuffer.t()) :: non_neg_integer()

Calculates the approximate memory usage of a single screen buffer.

This is a rough estimation based on buffer dimensions and an estimated cell size.

estimate_usage(width, height, scrollback_height)

@spec estimate_usage(pos_integer(), pos_integer(), pos_integer()) :: non_neg_integer()

Estimates the approximate memory usage for a given set of dimensions.

get_total_usage(active_buffer, back_buffer)

Calculates the total approximate memory usage for two buffers (active and back).

is_within_limit?(current_usage, memory_limit)

@spec is_within_limit?(non_neg_integer(), non_neg_integer()) :: boolean()

Checks if the given memory usage is within the specified limit.

trim_scrollback(scrollback)

@spec trim_scrollback([[Raxol.Terminal.Cell.t()]]) :: [[Raxol.Terminal.Cell.t()]]

Trims the scrollback buffer to the specified limit.