15 #include <mrpt/config.h> 20 #include <mach/mach_init.h> 21 #include <mach/task.h> 39 #if defined(HAVE_ALIGNED_MALLOC) 40 # if defined(__GNUC__) && !defined(__MINGW32__) 43 return _aligned_malloc(bytes,alignment);
45 #elif defined(HAVE_POSIX_MEMALIGN) 47 int ret = posix_memalign(&ptr,alignment,bytes);
52 return ::malloc(bytes);
63 #if defined(HAVE_ALIGNED_MALLOC) 64 # if defined(__GNUC__) && !defined(__MINGW32__) 67 return _aligned_realloc(old_ptr,bytes,alignment);
69 #elif defined(HAVE_POSIX_MEMALIGN) 71 return ::realloc(old_ptr,bytes);
75 return ::realloc(old_ptr,bytes);
84 #if defined(HAVE_ALIGNED_MALLOC) 85 # if defined(__GNUC__) && !defined(__MINGW32__) 90 #elif defined(HAVE_POSIX_MEMALIGN) 99 #ifdef MRPT_OS_WINDOWS 102 typedef struct _PROCESS_MEMORY_COUNTERS {
104 DWORD PageFaultCount;
105 SIZE_T PeakWorkingSetSize;
106 SIZE_T WorkingSetSize;
107 SIZE_T QuotaPeakPagedPoolUsage;
108 SIZE_T QuotaPagedPoolUsage;
109 SIZE_T QuotaPeakNonPagedPoolUsage;
110 SIZE_T QuotaNonPagedPoolUsage;
111 SIZE_T PagefileUsage;
112 SIZE_T PeakPagefileUsage;
113 } PROCESS_MEMORY_COUNTERS,
114 *PPROCESS_MEMORY_COUNTERS;
124 class CAuxPSAPI_Loader
127 typedef BOOL (WINAPI *TGetProcessMemoryInfo)(
129 PPROCESS_MEMORY_COUNTERS ppsmemCounters,
132 TGetProcessMemoryInfo m_ptr;
141 m_dll = LoadLibraryA(
"PSAPI.DLL");
144 m_ptr = (TGetProcessMemoryInfo) GetProcAddress(m_dll,
"GetProcessMemoryInfo");
157 BOOL WINAPI GetProcessMemoryInfo(
159 PPROCESS_MEMORY_COUNTERS ppsmemCounters,
166 else return (*m_ptr )(Process,ppsmemCounters,cb);
185 unsigned long MEM = 0;
187 #ifdef MRPT_OS_WINDOWS 189 static CAuxPSAPI_Loader PSAPI_LOADER;
191 PROCESS_MEMORY_COUNTERS pmc;
192 pmc.cb =
sizeof(pmc);
194 if ( PSAPI_LOADER.GetProcessMemoryInfo( GetCurrentProcess(),&pmc,
sizeof(pmc) ) )
196 MEM = (long)pmc.PagefileUsage;
204 FILE *f =
::fopen (
"/proc/self/stat",
"r");
211 "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %*d %*d %*u %lu", &
MEM))
221 mach_task_basic_info
info;
222 mach_msg_type_number_t
count = MACH_TASK_BASIC_INFO_COUNT;
223 if(task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&
info, &
count)==0)
GLuint GLuint GLsizei count
FILE BASE_IMPEXP * fopen(const char *fileName, const char *mode) MRPT_NO_THROWS
An OS-independent version of fopen.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
int BASE_IMPEXP void BASE_IMPEXP fclose(FILE *f)
An OS-independent version of fclose.
#define THROW_EXCEPTION(msg)
void BASE_IMPEXP * aligned_realloc(void *old_ptr, size_t bytes, size_t alignment)
Frees a memory block reserved by aligned_malloc.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
unsigned long BASE_IMPEXP getMemoryUsage()
Returns the memory occupied by this process, in bytes.
void BASE_IMPEXP * aligned_malloc(size_t bytes, size_t alignment)
Returns an aligned memory block.
void BASE_IMPEXP aligned_free(void *p)
Frees a memory block reserved by aligned_malloc.