mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 16:33:53 +01:00
ircd::allocator: Add trim() if available.
This commit is contained in:
parent
7dd23cd4f0
commit
55a8391e48
2 changed files with 18 additions and 0 deletions
|
@ -24,6 +24,8 @@ namespace ircd::allocator
|
|||
template<class T = char> struct dynamic;
|
||||
template<class T = char, size_t = 512> struct fixed;
|
||||
template<class T> struct node;
|
||||
|
||||
bool trim(const size_t &pad = 0); // malloc_trim(3)
|
||||
};
|
||||
|
||||
/// Profiling counters.
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#include <RB_INC_MALLOC_H
|
||||
|
||||
// Uncomment or -D this #define to enable our own crude but simple ability to
|
||||
// profile dynamic memory usage. Global `new` and `delete` will be captured
|
||||
// here by this definition file into thread_local counters accessible via
|
||||
|
@ -16,6 +18,20 @@
|
|||
//
|
||||
// #define RB_PROF_ALLOC
|
||||
|
||||
#if defined(__GNU_LIBRARY__) && defined(HAVE_MALLOC_H)
|
||||
bool
|
||||
ircd::allocator::trim(const size_t &pad)
|
||||
{
|
||||
return malloc_trim(pad);
|
||||
}
|
||||
#else
|
||||
bool
|
||||
ircd::allocator::trim(const size_t &pad)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// allocator::state
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue