/usr/include/InsightToolkit/Common/itkMemoryUsageObserver.h is in libinsighttoolkit3-dev 3.20.1-1.
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 152 153 154 155 156 157 158 159 160 161 162 163 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkMemoryUsageObserver.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkMemoryUsageObserver_h
#define __itkMemoryUsageObserver_h
#include "itkConfigure.h"
#include "itkMacro.h"
#include "itkObject.h"
#include "itkObjectFactory.h"
#if defined(WIN32) || defined(_WIN32)
#include <windows.h>
#define SUPPORT_TOOLHELP32
#if defined(SUPPORT_TOOLHELP32)
typedef LONG NTSTATUS;
#endif
#endif
namespace itk
{
/** \class MemoryUsageObserver
* \brief The MemoryUsageObserver provides the memory usage of the process
*
* This class represents a memory load analyser object
* and provides a memory usage in platform-independent format.
*
*/
class ITKCommon_EXPORT MemoryUsageObserverBase
{
public:
/** Define the type for the memory usage */
typedef unsigned long MemoryLoadType;
/** destructor */
virtual ~MemoryUsageObserverBase();
/** Returns the memory load in kO */
virtual MemoryLoadType GetMemoryUsage() = 0;
};
#if defined(WIN32) || defined(_WIN32)
class ITKCommon_EXPORT WindowsMemoryUsageObserver:public MemoryUsageObserverBase
{
public:
WindowsMemoryUsageObserver();
/** destructor */
virtual ~WindowsMemoryUsageObserver();
/** Returns the memory load in kO */
virtual MemoryLoadType GetMemoryUsage();
protected:
#if defined(SUPPORT_TOOLHELP32)
typedef NTSTATUS (WINAPI * PZwQuerySystemInformation)(UINT, PVOID, ULONG, PULONG);
// handle ntdll.dll library
HMODULE m_hNTLib;
// Windows native API function to query system information
PZwQuerySystemInformation ZwQuerySystemInformation;
#endif // defined(SUPPORT_TOOLHELP32)
};
#endif // defined(WIN32) || defined(_WIN32)
#ifdef linux
class ITKCommon_EXPORT LinuxMemoryUsageObserver:public MemoryUsageObserverBase
{
public:
/** destructor */
virtual ~LinuxMemoryUsageObserver();
virtual MemoryLoadType GetMemoryUsage();
};
#endif // linux
#if defined(__APPLE__) && MAC_OS_X_VERSION >= MAC_OS_X_VERSION_10_2
class ITKCommon_EXPORT MacOSXMemoryUsageObserver:public MemoryUsageObserverBase
{
public:
/** destructor */
virtual ~MacOSXMemoryUsageObserver();
virtual MemoryLoadType GetMemoryUsage();
};
#endif // Mac OS X
#if defined(__SUNPRO_CC) || defined (__sun__)
class ITKCommon_EXPORT SunSolarisMemoryUsageObserver:public MemoryUsageObserverBase
{
public:
/** destructor */
virtual ~SunSolarisMemoryUsageObserver();
virtual MemoryLoadType GetMemoryUsage();
};
#endif // Sun Solaris
#if !defined(WIN32) && !defined(_WIN32)
class ITKCommon_EXPORT SysResourceMemoryUsageObserver:public MemoryUsageObserverBase
{
public:
/** destructor */
virtual ~SysResourceMemoryUsageObserver();
virtual MemoryLoadType GetMemoryUsage();
};
#if !defined( __APPLE__ ) && !defined( __SUNPRO_CC ) && !defined ( __sun__ ) && !defined( __FreeBSD__ ) \
&& !defined( __OpenBSD__ )
/** \class MallinfoMemoryUsageObserver
* \brief The MallinfoMemoryUsageObserver
*/
class ITKCommon_EXPORT MallinfoMemoryUsageObserver:public MemoryUsageObserverBase
{
public:
/** destructor */
virtual ~MallinfoMemoryUsageObserver();
virtual MemoryLoadType GetMemoryUsage();
};
#endif // Mallinfo
#endif // !defined(WIN32) && !defined(_WIN32)
/* \class MemoryUsageObserver
* The best MemoryUsageObserver has been chosen for each OS.
* However, SysResourceMemoryUsageObserver is far from being accurate. Other
* way of getting the Memory Usage shall be used.
* For FreeBSD, some alternatives would be to parse the output of
* "sysctl vm.vmtotal" or "sysctl -a | grep -i memory"
*/
class ITKCommon_EXPORT MemoryUsageObserver:
#if defined(WIN32) || defined(_WIN32)
public WindowsMemoryUsageObserver
#elif defined(linux)
public LinuxMemoryUsageObserver
#elif defined(__SUNPRO_CC) || defined (__sun__)
public SunSolarisMemoryUsageObserver
#elif defined(__APPLE__) && MAC_OS_X_VERSION >= MAC_OS_X_VERSION_10_2
public MacOSXMemoryUsageObserver
#elif defined( __APPLE__ ) || defined( __FreeBSD__ ) || defined( __OpenBSD__ )
public SysResourceMemoryUsageObserver
#else
public MallinfoMemoryUsageObserver
#endif
{
public:
/** destructor */
virtual ~MemoryUsageObserver(){}
};
} // end of namespace itk
#endif // __itkMemoryUsageObserver_h
|