/usr/include/stxxl/bits/utils/malloc.h is in libstxxl-dev 1.3.1-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | /***************************************************************************
* include/stxxl/bits/utils/malloc.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2003 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#ifndef STXXL_MALLOC_H
#define STXXL_MALLOC_H
#include <ostream>
#ifdef __FreeBSD__
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#include <cstdlib>
#include <stxxl/bits/namespace.h>
__STXXL_BEGIN_NAMESPACE
//! \brief Access to some useful malloc statistics
//! malloc is default C++ allocator
class malloc_stats
{
#if !defined(__APPLE__) && !defined(__FreeBSD__)
public:
typedef int return_type;
//! \brief Returns number of bytes allocated from system not including mmapped regions
return_type from_system_nmmap() const
{
struct mallinfo info = mallinfo();
return info.arena;
}
//! \brief Returns number of free chunks
return_type free_chunks() const
{
struct mallinfo info = mallinfo();
return info.ordblks;
}
//! \brief Number of bytes allocated and in use
return_type used() const
{
struct mallinfo info = mallinfo();
return info.uordblks;
}
//! \brief Number of bytes allocated but not in use
return_type not_used() const
{
struct mallinfo info = mallinfo();
return info.fordblks;
}
//! \brief Top-most, releasable (via malloc_trim) space (bytes)
return_type releasable() const
{
struct mallinfo info = mallinfo();
return info.keepcost;
}
//! \brief Maximum total allocated space (bytes) (always 0 ?)
return_type max_allocated() const
{
struct mallinfo info = mallinfo();
return info.usmblks;
}
//! \brief Number of fastbin blocks
return_type fastbin_blocks() const
{
struct mallinfo info = mallinfo();
return info.smblks;
}
//! \brief Space available in freed fastbin blocks (bytes)
return_type fastbin_free() const
{
struct mallinfo info = mallinfo();
return info.fsmblks;
}
//! \brief Returns number of bytes allocated from system using mmap
return_type from_system_mmap() const
{
struct mallinfo info = mallinfo();
return info.hblkhd;
}
//! \brief Number of chunks allocated via mmap()
return_type mmap_chunks() const
{
struct mallinfo info = mallinfo();
return info.hblks;
}
//! \brief Returns \b total number of bytes allocated from system including mmapped regions
return_type from_system_total() const
{
return from_system_nmmap() + from_system_mmap();
}
#endif
};
//! \brief Prints current malloc statistics in a convenient way
inline std::ostream & operator << (std::ostream & s, const malloc_stats & st)
{
#if !defined(__APPLE__) && !defined(__FreeBSD__)
s << "MALLOC statistics" << std::endl;
s << "=================================================================" << std::endl;
s << "Space allocated from system not using mmap: " << st.from_system_nmmap() << " bytes" << std::endl;
s << " number of free chunks : " << st.free_chunks() << std::endl;
s << " space allocated and in use : " << st.used() << " bytes" << std::endl;
s << " space allocated but not in use : " << st.not_used() << " bytes" << std::endl;
s << " top-most, releasable (via malloc_trim) space: " << st.releasable() << " bytes" << std::endl;
s << " maximum total allocated space (?) : " << st.max_allocated() << " bytes" << std::endl;
s << " FASTBIN blocks " << std::endl;
s << " number of fastbin blocks: " << st.fastbin_blocks() << std::endl;
s << " space available in freed fastbin blocks: " << st.fastbin_free() << " bytes" << std::endl;
s << "Space allocated from system using mmap: " << st.from_system_mmap() << " bytes" << std::endl;
s << " number of chunks allocated via mmap(): " << st.mmap_chunks() << std::endl;
s << "Total space allocated from system (mmap and not mmap): " <<
st.from_system_total() << " bytes" << std::endl;
s << "=================================================================" << std::endl;
#else
s << "MALLOC statistics are not supported on this platform";
STXXL_UNUSED(st);
#endif
return s;
}
class malloc_setup
{ };
__STXXL_END_NAMESPACE
#endif // !STXXL_MALLOC_H
|