HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ArenaInfo.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ArenaInfo.h
7  *
8  * COMMENTS:
9  * This is a simple interface to mallinfo or some alternative
10  * if this is not available.
11  */
12 
13 #ifndef __UT_ArenaInfo__
14 #define __UT_ArenaInfo__
15 
16 #include "UT_API.h"
17 
18 #include <SYS/SYS_Allocator.h>
19 
20 #include <stddef.h>
21 #include <iosfwd>
22 
23 class UT_StringHolder;
24 class UT_WorkBuffer;
25 
27 {
28 public:
29  // Arena size is a bit old school. Just use totalInUse.
30  static size_t arenaSize();
31  static size_t totalInUse();
32 
33  /// Print memory/arena usage to the stream (with a terminating new line)
34  static void outputUsage(std::ostream &os, const bool output_in_bytes=false,
35  const bool debug=false);
36 
37  /// Print memory usage into a work buffer (without terminating new line)
38  static void outputUsage(UT_WorkBuffer &wbuf, const bool in_bytes=false,
39  const bool debug=false);
40 
41  static bool usingCustomAllocator();
42  static UT_StringHolder
43  customAllocatorName();
44 
45  static void configureCustomAllocator();
46 
47  static bool customAllocatorTestDisabled();
48 
49  static UT_StringHolder
50  customAllocatorTestDisabledMessage();
51 
52  static void setThreadIdle();
53  static void setThreadBusy();
54 
55  static void releaseAllUnusedMemory();
56 
57 private:
58 #if defined(SYS_ALLOCATOR_TCMALLOC)
59  /// Returns true if the current session has successfully bound tcmalloc.
60  static bool usingTCMalloc();
61 
62  /// Set our config options for tcmalloc. Note that this should be (re)done
63  /// after forking since some options may be reset.
64  static void configureTCMalloc();
65 #elif defined(SYS_ALLOCATOR_MIMALLOC)
66  /// Returns true if the current session has successfully bound mimalloc.
67  static bool usingMIMalloc();
68 
69  /// Set our config options for mimalloc. Note that this should be (re)done
70  /// after forking since some options may be reset.
71  static void configureMIMalloc();
72 #else
73  /// Returns true if the current session has successfully bound
74  /// JE Malloc.
75  static bool usingJEMalloc();
76 
77  /// Set our config options for jemalloc. Note that this should be (re)done
78  /// after forking since some options may be reset.
79  static void configureJEMalloc();
80 #endif
81 };
82 
83 #endif /* __UT_ArenaInfo__ */
#define UT_API
Definition: UT_API.h:14