ATLAS Offline Software
Functions | Variables
memory_hooks-tcmalloc.h File Reference
#include "CxxUtils/checker_macros.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdint>
#include <string.h>
#include <stdlib.h>
#include <gperftools/malloc_extension.h>
#include <gperftools/malloc_hook.h>
#include <gperftools/stacktrace.h>
#include "gperftools/tcmalloc.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int MallocHook_RemoveNewHook (MallocHook_NewHook)
 
int MallocHook_RemoveDeleteHook (MallocHook_DeleteHook)
 
int MallocHook_AddNewHook (MallocHook_NewHook)
 
int MallocHook_AddDeleteHook (MallocHook_DeleteHook)
 
int MallocHook_AddMmapHook (MallocHook_MmapHook)
 
int MallocHook_AddMunmapHook (MallocHook_MunmapHook)
 
void athena_NewHook (const void *ptr, size_t size)
 
void athena_DeleteHook (const void *ptr)
 
void athena_MmapHook (const void *, const void *, size_t, int, int, int, off_t)
 
void athena_MunmapHook (const void *, size_t)
 
void uninstall ()
 
void my_init_tcmalloc ()
 

Variables

 ATLAS_NO_CHECK_FILE_THREAD_SAFETY
 

Function Documentation

◆ athena_DeleteHook()

void athena_DeleteHook ( const void *  ptr)

Definition at line 81 of file memory_hooks-tcmalloc.h.

82 {
83  counter_tc_f++;
84  if(ptr==nullptr)
85  {
86  counter_tc_mtf++;
87  return;
88  }
89 
91  if ( allocset_last == allocset_tc.end() || allocset_last->allocated != (uintptr_t)ptr )
92  {
93  bg_tc->allocated=(uintptr_t)ptr;
94  allocSet_tc::iterator i = allocset_tc.find( *bg_tc );
95  if ( i != allocset_tc.end() )
96  {
97  allocset_tc.erase_and_dispose(i, allocSet_deleter());
98  }
99  }
100  else
101  {
102  counter_fna++;
103  // std::cerr << "TCMALLOC delete-last\n";
104  allocset_tc.erase(allocset_last);
105  delete &(*allocset_last);
106  allocset_last = allocset_tc.end();
107  }
109 }

◆ athena_MmapHook()

void athena_MmapHook ( const void *  ,
const void *  ,
size_t  ,
int  ,
int  ,
int  ,
off_t   
)

Definition at line 112 of file memory_hooks-tcmalloc.h.

119 {
120  counter_tc_mm++;
121  // std::cerr << "TCMALLOC mmap" << std::hex << result << " " << size << std::dec << "\n";
122 }

◆ athena_MunmapHook()

void athena_MunmapHook ( const void *  ,
size_t   
)

Definition at line 124 of file memory_hooks-tcmalloc.h.

125 {
126  counter_tc_mum++;
127  // std::cerr << "TCMALLOC munmap " << std::hex << ptr << " " << size << std::dec << "\n";
128 }

◆ athena_NewHook()

void athena_NewHook ( const void *  ptr,
size_t  size 
)

Definition at line 60 of file memory_hooks-tcmalloc.h.

61 {
62  counter_tc_m++;
63 
65  myBlocks_tc *b = new myBlocks_tc( (uintptr_t)ptr, size, curIndex, current_stage, stacktraceDepth );
66 
67  if(collectStacktraces)
68  {
69  b->allocatedFrom.resize(stacktraceDepth);
70  unw_backtrace (b->allocatedFrom.data(), b->allocatedFrom.capacity());
71  }
72  std::pair<allocSet_tc::iterator, bool> i = allocset_tc.insert( *b );
73  if(!i.second)
74  {
75  std::cerr << "ALREADY EXISTING " << std::hex << ptr << std::dec << "\n";
76  }
77  allocset_last=i.first;
79 }

◆ MallocHook_AddDeleteHook()

int MallocHook_AddDeleteHook ( MallocHook_DeleteHook  )

Definition at line 50 of file memory_hooks-tcmalloc.h.

51 { std::cerr << "TCMALLOC HOOKS: AddDeleteHook - Should not be here\n"; abort(); return 1; }

◆ MallocHook_AddMmapHook()

int MallocHook_AddMmapHook ( MallocHook_MmapHook  )

Definition at line 53 of file memory_hooks-tcmalloc.h.

54 { std::cerr << "TCMALLOC HOOKS: AddMmapHook - Should not be here\n"; abort(); return 1; }

◆ MallocHook_AddMunmapHook()

int MallocHook_AddMunmapHook ( MallocHook_MunmapHook  )

Definition at line 55 of file memory_hooks-tcmalloc.h.

56 { std::cerr << "TCMALLOC HOOKS: AddMunmapHook - Should not be here\n"; abort(); return 1; }

◆ MallocHook_AddNewHook()

int MallocHook_AddNewHook ( MallocHook_NewHook  )

Definition at line 48 of file memory_hooks-tcmalloc.h.

49 { std::cerr << "TCMALLOC HOOKS: AddNewHook - Should not be here\n"; abort(); return 1; }

◆ MallocHook_RemoveDeleteHook()

int MallocHook_RemoveDeleteHook ( MallocHook_DeleteHook  )

Definition at line 46 of file memory_hooks-tcmalloc.h.

47 { std::cerr << "TCMALLOC HOOKS: RemoveDeleteHook - Should not be here\n"; abort(); return 1; }

◆ MallocHook_RemoveNewHook()

int MallocHook_RemoveNewHook ( MallocHook_NewHook  )

Definition at line 44 of file memory_hooks-tcmalloc.h.

45 { std::cerr << "TCMALLOC HOOKS: RemoveNewHook - Should not be here\n"; abort(); return 1; }

◆ my_init_tcmalloc()

void my_init_tcmalloc ( )

Definition at line 136 of file memory_hooks-tcmalloc.h.

137 {
138  bg_tc = new myBlocks_tc();
139  allocset_last=allocset_tc.end();
140 
141  if(MallocHook::AddNewHook(&athena_NewHook))
142  std::cerr << "TCMALLOC NEW HOOK OK\n";
143  if(MallocHook::AddDeleteHook(&athena_DeleteHook))
144  std::cerr << "TCMALLOC DELETE HOOK OK\n";
145  if(MallocHook::AddMmapHook(&athena_MmapHook))
146  std::cerr << "TCMALLOC MMAP HOOK OK\n";
147  if(MallocHook::AddMunmapHook(&athena_MunmapHook))
148  std::cerr << "TCMALLOC MUNMAP HOOK OK\n";
149 
150  initialized=true;
151 }

◆ uninstall()

void uninstall ( )

Variable Documentation

◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY

ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Definition at line 15 of file memory_hooks-tcmalloc.h.

xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
bg_tc
myBlocks_tc * bg_tc
Definition: memory_hooks-common.h:107
MallocHook_RemoveNewHook
int MallocHook_RemoveNewHook(MallocHook_NewHook)
Definition: memory_hooks-tcmalloc.h:44
athena_DeleteHook
void athena_DeleteHook(const void *ptr)
Definition: memory_hooks-tcmalloc.h:81
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
myBlocks_tc::allocated
uintptr_t allocated
Definition: memory_hooks-common.h:68
MallocHook_RemoveDeleteHook
int MallocHook_RemoveDeleteHook(MallocHook_DeleteHook)
Definition: memory_hooks-tcmalloc.h:46
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
allocSet_deleter
std::default_delete< myBlocks_tc > allocSet_deleter
Definition: memory_hooks-common.h:110
myBlocks_tc
Definition: memory_hooks-common.h:66
athena_MmapHook
void athena_MmapHook(const void *, const void *, size_t, int, int, int, off_t)
Definition: memory_hooks-tcmalloc.h:112
lumiFormat.i
int i
Definition: lumiFormat.py:85
athena_NewHook
void athena_NewHook(const void *ptr, size_t size)
Definition: memory_hooks-tcmalloc.h:60
MallocHook_AddNewHook
int MallocHook_AddNewHook(MallocHook_NewHook)
Definition: memory_hooks-tcmalloc.h:48
MallocHook_AddDeleteHook
int MallocHook_AddDeleteHook(MallocHook_DeleteHook)
Definition: memory_hooks-tcmalloc.h:50
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
athena_MunmapHook
void athena_MunmapHook(const void *, size_t)
Definition: memory_hooks-tcmalloc.h:124