lean4-htt/src/util/memory.h
Leonardo de Moura db4b00c7d8 chore(util,library): remove small_object_allocator
We use small_object_allocator to allocate vm_obj's.
However small_object_allocator is not thread safe. So, we need to copy
vm_obj's between threads. Moreover, in our experiments, we observed that
JEMALLOC is actually faster than the small_object_allocator.

Here are numbers for the reduced corelib.

small_object_allocator:  15.62 secs
gcc 4.9 allocator:       16.19 secs
jemalloc:                13.83 secs
2018-04-12 16:43:10 -07:00

27 lines
827 B
C++

/*
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include <cstdlib>
namespace lean {
/** \brief Set maximum amount of memory in bytes */
void set_max_memory(size_t max);
/** \brief Set maximum amount of memory in megabytes */
void set_max_memory_megabyte(unsigned max);
void check_memory(char const * component_name);
size_t get_allocated_memory();
#ifdef LEAN_TRACK_CUSTOM_ALLOCATORS
/* We use report_memory_deallocated to track memory released by custom allocators such
as memory_pool. */
void report_memory_deallocated(size_t s);
size_t get_memory_deallocated();
#define lean_report_memory_deallocated(s) report_memory_deallocated(s)
#else
#define lean_report_memory_deallocated(s)
#endif
}