Skip to content

Managing memoryđź”—

Memory management ensures that applications always have fast and sufficient access to the memory of the computer hosting the application. Managing main memory is crucial for an application’s memory usage and speed.

The sections below focus solely on main memory (RAM) within the memory hierarchy.


From a software perspective, HALCON’s memory management can be represented as a hierarchy:

  1. The operating system (OS) manages memory in pages, which are made available to a process such as HALCON. For the x86_64 architecture, these are 4 KB or 2 MB in size.

  2. In the process’s runtime environment, a memory allocator is provided, enabling software to request and release memory from the system.

    • Under Linux, HALCON uses malloc/free from the C runtime library by default. mimalloc can also be set using set_system.
    • Under Windows, HALCON version 22.11 until 26.05 used Microsoft Research’s mimalloc allocator as the default and alternatively the Win32 default heap. Starting with version 26.11, HALCON uses the Win32 heap per default. For more information, see the corresponding Microsoft documentation.

    Important

    These allocators typically maintain their own caches, beyond HALCON’s control. This can lead to HALCON releasing all memory, but from the system’s point of view, the process may still occupy memory, which is actually being held within the allocator’s cache.

  3. HALCON itself uses the memory allocator of the system, and places the caches on top.