Go to the documentation of this file.00001 #ifndef OPENTISSUE_UTILITY_UTILITY_GET_SYSTEM_MEMORY_INFO_H
00002 #define OPENTISSUE_UTILITY_UTILITY_GET_SYSTEM_MEMORY_INFO_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #ifdef WIN32
00013 # define NOMINMAX
00014 # define WIN32_LEAN_AND_MEAN
00015 # include <windows.h>
00016 # undef WIN32_LEAN_AND_MEAN
00017 # undef NOMINMAX
00018 #endif
00019
00020 namespace OpenTissue
00021 {
00022 namespace utility
00023 {
00024
00025 #ifdef WIN32
00026
00027 double get_memory_usage()
00028 {
00029 typedef double real_type;
00030 MEMORYSTATUSEX statex;
00031 statex.dwLength = sizeof (statex);
00032 GlobalMemoryStatusEx (&statex);
00033 real_type memory_usage = statex.dwMemoryLoad;
00034 return memory_usage;
00035 }
00036
00037 unsigned int get_total_physical_memory_in_bytes()
00038 {
00039 MEMORYSTATUSEX statex;
00040 statex.dwLength = sizeof (statex);
00041 GlobalMemoryStatusEx (&statex);
00042 unsigned int total_physical_memory_in_bytes = statex.ullTotalPhys;
00043 return total_physical_memory_in_bytes;
00044 }
00045
00046 unsigned int get_free_physical_memory_in_bytes()
00047 {
00048 MEMORYSTATUSEX statex;
00049 statex.dwLength = sizeof (statex);
00050 GlobalMemoryStatusEx (&statex);
00051 unsigned int free_physical_memory_in_bytes = statex.ullAvailPhys;
00052 return free_physical_memory_in_bytes;
00053 }
00054
00055 unsigned int get_total_page_file_in_bytes()
00056 {
00057 MEMORYSTATUSEX statex;
00058 statex.dwLength = sizeof (statex);
00059 GlobalMemoryStatusEx (&statex);
00060 unsigned int total_page_file_in_bytes = statex.ullTotalPageFile;
00061 return total_page_file_in_bytes;
00062 }
00063
00064 unsigned int get_free_page_file_in_bytes()
00065 {
00066 MEMORYSTATUSEX statex;
00067 statex.dwLength = sizeof (statex);
00068 GlobalMemoryStatusEx (&statex);
00069 unsigned int free_page_file_in_bytes = statex.ullAvailPageFile;
00070 return free_page_file_in_bytes;
00071 }
00072
00073 unsigned int get_total_virtual_memory_in_bytes()
00074 {
00075 MEMORYSTATUSEX statex;
00076 statex.dwLength = sizeof (statex);
00077 GlobalMemoryStatusEx (&statex);
00078 unsigned int total_virtual_memory = statex.ullTotalVirtual;
00079 return total_virtual_memory;
00080 }
00081
00082 unsigned int get_free_virtual_memory_in_bytes()
00083 {
00084 MEMORYSTATUSEX statex;
00085 statex.dwLength = sizeof (statex);
00086 GlobalMemoryStatusEx (&statex);
00087 unsigned int free_virtual_memory_in_bytes = statex.ullAvailVirtual;
00088 return free_virtual_memory;
00089 }
00090
00091 unsigned int get_free_extended_memory_in_bytes()
00092 {
00093 MEMORYSTATUSEX statex;
00094 statex.dwLength = sizeof (statex);
00095 GlobalMemoryStatusEx (&statex);
00096 unsigned int free_extended_memory_in_bytes = statex.ullAvailExtendedVirtual;
00097 return free_extended_memory_in_bytes;
00098 }
00099
00100
00101 #endif
00102
00103 }
00104
00105 }
00106
00107
00108 #endif