meminfo.c File Reference
#include "lib/meminfo/meminfo.h"
#include "lib/cc/compat_compiler.h"
#include "lib/cc/torint.h"
#include "lib/fs/files.h"
#include "lib/log/log.h"
#include "lib/malloc/malloc.h"
#include <string.h>

Go to the source code of this file.


void tor_log_mallinfo (int severity)
static uint64_t get_total_system_memory_impl (void)
 MOCK_IMPL (int, get_total_system_memory,(size_t *mem_out))

Detailed Description

Functions to query total memory, and access meta-information about the allocator.

Definition in file meminfo.c.

Function Documentation

◆ get_total_system_memory_impl()

static uint64_t get_total_system_memory_impl ( void  )

Helper: try to detect the total system memory, and return it. On failure, return 0.

Definition at line 76 of file meminfo.c.

References read_file_to_str_until_eof(), tor_free, and tor_open_cloexec().

Referenced by MOCK_IMPL().


MOCK_IMPL ( int  ,
get_total_system_memory  ,
(size_t *mem_out)   

Try to find out how much physical memory the system has. On success, return 0 and set *mem_out to that value. On failure, return -1.

Definition at line 150 of file meminfo.c.

References get_total_system_memory_impl().

◆ tor_log_mallinfo()

void tor_log_mallinfo ( int  severity)

Call the platform malloc info function, and dump the results to the log at level severity. If no such function exists, do nothing.

Definition at line 44 of file meminfo.c.

References LD_MM, and tor_log().

Referenced by dumpmemusage().