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

View Source

Handles calculation and checking of terminal buffer memory usage.

Summary

Functions

Calculates the approximate memory usage of a single screen buffer.

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

Checks if the given memory usage is within 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.

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.