Raxol.Terminal.Buffer.Manager.Memory (Raxol v0.5.0)

View Source

Handles memory management for the terminal buffer. Provides functionality for tracking memory usage and enforcing limits.

Summary

Functions

Calculates memory usage for a specific buffer.

Estimates memory usage for a given buffer size.

Gets the memory limit.

Gets the current memory usage.

Sets a new memory limit.

Updates memory usage tracking.

Checks if memory usage is within limits.

Checks if a given buffer size would exceed memory limits.

Functions

calculate_buffer_usage(buffer)

Calculates memory usage for a specific buffer.

Examples

iex> state = State.new(80, 24)
iex> Memory.calculate_buffer_usage(state.active_buffer) > 0
true

estimate_usage(width, height, scrollback_height)

Estimates memory usage for a given buffer size.

Examples

iex> Memory.estimate_usage(80, 24, 1000) > 0
true

get_limit(state)

Gets the memory limit.

Examples

iex> state = State.new(80, 24)
iex> Memory.get_limit(state)
10_000_000

get_usage(state)

Gets the current memory usage.

Examples

iex> state = State.new(80, 24)
iex> state = Memory.update_usage(state)
iex> Memory.get_usage(state) > 0
true

set_limit(state, new_limit)

Sets a new memory limit.

Examples

iex> state = State.new(80, 24)
iex> state = Memory.set_limit(state, 5_000_000)
iex> Memory.get_limit(state)
5_000_000

update_usage(state)

Updates memory usage tracking.

Examples

iex> state = State.new(80, 24)
iex> state = Memory.update_usage(state)
iex> state.memory_usage > 0
true

within_limits?(state)

Checks if memory usage is within limits.

Examples

iex> state = State.new(80, 24)
iex> Memory.within_limits?(state)
true

would_exceed_limit?(state, width, height, scrollback_height)

Checks if a given buffer size would exceed memory limits.

Examples

iex> state = State.new(80, 24)
iex> Memory.would_exceed_limit?(state, 100, 50, 2000)
false