Skip to content

Monitor Archicad memory use

Use a header's ram_monitor to inspect process memory and record observed peaks. A batch runner can use this information when deciding how many projects to open. Memory monitoring does not impose a resource limit or schedule work for you.

This read-only helper measures memory while counting walls:

from multiconn_archicad import ConnHeader, is_session_ready
from multiconn_archicad.models.official.types import ElementType


def count_with_memory_report(header: ConnHeader) -> int:
    if not is_session_ready(header):
        raise RuntimeError("Wait for a ready Archicad project.")
    with header.ram_monitor.track(interval_s=0.1):
        walls = header.unified.official.element_listing.get_elements_by_type(ElementType.WALL)
    peak = header.peak_archicad_ram_bytes
    if peak is not None:
        print(f"Observed peak: {peak / (1024 ** 3):.2f} GiB")
    return len(walls)

header.ram_monitor.current_bytes reads current resident memory and updates the observed peak. Values are bytes; dividing by 1024 ** 3 gives GiB. The reading can be None when the process cannot be identified or measured.

Polling at 0.1 seconds can miss shorter spikes. Treat the observed peak as a measurement, not a guaranteed maximum or a reservation for the next run. Saved header data can retain a historical peak for later capacity decisions.