当前位置: 首页>>代码示例>>C++>>正文


C++ GlobalMemoryStatusEx函数代码示例

本文整理汇总了C++中GlobalMemoryStatusEx函数的典型用法代码示例。如果您正苦于以下问题:C++ GlobalMemoryStatusEx函数的具体用法?C++ GlobalMemoryStatusEx怎么用?C++ GlobalMemoryStatusEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GlobalMemoryStatusEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Sys_LowPhysicalMemory

/*
==================
Sys_LowPhysicalMemory
==================
*/
qboolean Sys_LowPhysicalMemory() 
{
	static MEMORYSTATUSEX stat;
	static qboolean bAsked = qfalse;
	static cvar_t* sys_lowmem = Cvar_Get( "sys_lowmem", "0", 0 );

	if (!bAsked)	// just in case it takes a little time for GlobalMemoryStatus() to gather stats on
	{				//	stuff we don't care about such as virtual mem etc.
		bAsked = qtrue;
		GlobalMemoryStatusEx (&stat);
	}
	if (sys_lowmem->integer)
	{
		return qtrue;
	}
	return (stat.ullTotalPhys <= MEM_THRESHOLD) ? qtrue : qfalse;
}
开发者ID:shadow95,项目名称:OpenJK,代码行数:22,代码来源:win_main.cpp

示例2: sizeof

/////////////////////////////////////////////////////////////////////
// GetMemoryInfo => 메모리에 대한 정보를 얻어온다. (단위 MB)
// dwTotalMemMB : 시스템 전체 메모리 용량
// dwAvailMemMB : 사용중인 메모리 용량
// dwVirtualMemMB : 가상메모리 전체 용량
/////////////////////////////////////////////////////////////////////
void MBMatchSystemInfo::GetMemoryInfo(DWORD* dwTotalMemMB, DWORD* dwAvailMemMB, DWORD* dwVirtualMemMB)
{
#ifdef _MONITORING
	MEMORYSTATUSEX statex;
	statex.dwLength = sizeof(statex);
	GlobalMemoryStatusEx(&statex);

	DWORDLONG lMemTotalMB = (statex.ullTotalPhys / (1024 * 1024));
	*dwTotalMemMB = (DWORD)lMemTotalMB;

	DWORDLONG lAvailMemMB = (statex.ullAvailPhys / (1024 * 1024));
	*dwAvailMemMB = (DWORD)lAvailMemMB;

	DWORDLONG lVirtualMemMB = (statex.ullTotalVirtual / (1024 * 1024));
	*dwVirtualMemMB = (DWORD)lVirtualMemMB;
#endif
}
开发者ID:roseon,项目名称:life-marvelous,代码行数:23,代码来源:MBMatchSystemInfo.cpp

示例3: getPhysicalMemorySize

/* Returns 0 if physical memory size cannot be identified */
StgWord64 getPhysicalMemorySize (void)
{
    static StgWord64 physMemSize = 0;
    if (!physMemSize) {
        MEMORYSTATUSEX status;
        status.dwLength = sizeof(status);
        if (!GlobalMemoryStatusEx(&status)) {
#if defined(DEBUG)
            errorBelch("warning: getPhysicalMemorySize: cannot get physical "
                       "memory size");
#endif
            return 0;
        }
        physMemSize = status.ullTotalPhys;
    }
    return physMemSize;
}
开发者ID:AaronFriel,项目名称:ghc,代码行数:18,代码来源:OSMem.c

示例4: physical_ram

	boost::uint64_t physical_ram()
	{
		boost::uint64_t ret = 0;
		// figure out how much physical RAM there is in
		// this machine. This is used for automatically
		// sizing the disk cache size when it's set to
		// automatic.
#ifdef TORRENT_BSD
#ifdef HW_MEMSIZE
		int mib[2] = { CTL_HW, HW_MEMSIZE };
#else
		// not entirely sure this sysctl supports 64
		// bit return values, but it's probably better
		// than not building
		int mib[2] = { CTL_HW, HW_PHYSMEM };
#endif
		size_t len = sizeof(ret);
		if (sysctl(mib, 2, &ret, &len, NULL, 0) != 0)
			ret = 0;
#elif defined TORRENT_WINDOWS
		MEMORYSTATUSEX ms;
		ms.dwLength = sizeof(MEMORYSTATUSEX);
		if (GlobalMemoryStatusEx(&ms))
			ret = ms.ullTotalPhys;
		else
			ret = 0;
#elif defined TORRENT_LINUX
		ret = sysconf(_SC_PHYS_PAGES);
		ret *= sysconf(_SC_PAGESIZE);
#elif defined TORRENT_AMIGA
		ret = AvailMem(MEMF_PUBLIC);
#endif

#if TORRENT_USE_RLIMIT
		if (ret > 0)
		{
			struct rlimit r;
			if (getrlimit(RLIMIT_AS, &r) == 0 && r.rlim_cur != RLIM_INFINITY)
			{
				if (ret > r.rlim_cur)
					ret = r.rlim_cur;
			}
		}
#endif
		return ret;
	}
开发者ID:steeve,项目名称:libtorrent,代码行数:46,代码来源:disk_buffer_pool.cpp

示例5: defined

/*==========================================================================*/
size_t SystemInformation::TotalMemorySize()
{
// Windows
#if defined ( KVS_PLATFORM_WINDOWS )
#if defined ( KVS_PLATFORM_CPU_64 )
    MEMORYSTATUSEX memstat;
    GlobalMemoryStatusEx( &memstat );
    return memstat.ullTotalPhys;
#else
    MEMORYSTATUS memstat;
    GlobalMemoryStatus( &memstat );
    return memstat.dwTotalPhys;
#endif

// Linux
#elif defined ( KVS_PLATFORM_LINUX ) || defined ( KVS_PLATFORM_CYGWIN )
    long phys_page_size = sysconf( _SC_PHYS_PAGES );
    kvsMessageWarning( phys_page_size != -1,
                       ::GetWarningMessage( errno, "_SC_PHYS_PAGES is not supported." ) );

    long page_size = sysconf( _SC_PAGESIZE );
    kvsMessageWarning( page_size != -1,
                       ::GetWarningMessage( errno, "_SC_PAGESIZE is not supported." ) );

    return phys_page_size * page_size;

// Mac OS X
#elif defined ( KVS_PLATFORM_MACOSX )
#if defined ( KVS_PLATFORM_CPU_64 )
    uint64_t memory_size = 0;
    size_t   length      = sizeof( memory_size );
    int      ret         = 0;
    ret = sysctlbyname( "hw.memsize", &memory_size, &length, NULL, 0 );
    kvsMessageWarning( ret != -1, strerror( errno ) );
    return memory_size;
#else
    uint32_t memory_size = 0;
    size_t   length      = sizeof( memory_size );
    int      ret         = 0;
    ret = sysctlbyname( "hw.physmem", &memory_size, &length, NULL, 0 );
    kvsMessageWarning( ret != -1, strerror( errno ) );
    return memory_size;
#endif
#endif
}
开发者ID:digirea,项目名称:KVS,代码行数:46,代码来源:SystemInformation.cpp

示例6: os_get_total_physical_memory

/**
 * Return the size of the total physical memory.
 * \param size returns the size of the total physical memory
 * \return true for success, or false on failure
 */
bool
os_get_total_physical_memory(uint64_t *size)
{
#if defined(PIPE_OS_LINUX)
   const long phys_pages = sysconf(_SC_PHYS_PAGES);
   const long page_size = sysconf(_SC_PAGE_SIZE);

   *size = phys_pages * page_size;
   return (phys_pages > 0 && page_size > 0);
#elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD)
   size_t len = sizeof(size);
   int mib[2];

   mib[0] = CTL_HW;
#if defined(PIPE_OS_APPLE)
   mib[1] = HW_MEMSIZE;
#elif defined(PIPE_OS_NETBSD) || defined(PIPE_OS_OPENBSD)
   mib[1] = HW_PHYSMEM64;
#elif defined(PIPE_OS_FREEBSD)
   mib[1] = HW_REALMEM;
#else
#error Unsupported *BSD
#endif

   return (sysctl(mib, 2, &size, &len, NULL, 0) == 0);
#elif defined(PIPE_OS_HAIKU)
   system_info info;
   status_t ret;

   ret = get_system_info(&info);
   *size = info.max_pages * B_PAGE_SIZE;
   return (ret == B_OK);
#elif defined(PIPE_OS_WINDOWS)
   MEMORYSTATUSEX status;
   BOOL ret;

   status.dwLength = sizeof(status);
   ret = GlobalMemoryStatusEx(&status);
   *size = status.ullTotalPhys;
   return (ret == TRUE);
#else
#error unexpected platform in os_sysinfo.c
   return false;
#endif
}
开发者ID:kallisti5,项目名称:mesa_intel,代码行数:50,代码来源:os_misc.c

示例7: l_freeMemory

static int l_freeMemory (lua_State *L) {
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
  MEMORYSTATUS status;
  status.dwLength = sizeof(status);
  GlobalMemoryStatus( &status );
  lua_pushnumber(L, status.dwAvailPhys);
#elif defined(_WIN32)
  MEMORYSTATUSEX status;
  status.dwLength = sizeof(status);
  GlobalMemoryStatusEx( &status );
  lua_pushnumber(L, (size_t)status.ullAvailPhys);
#else
  long pages = sysconf(_SC_AVPHYS_PAGES);
  long page_size = sysconf(_SC_PAGE_SIZE);
  lua_pushnumber(L, pages * page_size);
#endif
  return 1;
}
开发者ID:StarChasers,项目名称:LuPI2,代码行数:18,代码来源:lnative.c

示例8: platform_guess_reasonable_maxmemory

/* Make a guess for a reasonable amount of memory for the hashtable
 * @return number of kilo-bytes to be used
 */
unsigned long platform_guess_reasonable_maxmemory(void)
{
    unsigned long const one_giga = 1024*1024;
    unsigned long result = one_giga;

    MEMORYSTATUSEX memstatEx;
    memstatEx.dwLength = sizeof memstatEx;
    if (GlobalMemoryStatusEx(&memstatEx))
    {
        unsigned long const one_kilo = 1024;
        unsigned long long const available_kilos = memstatEx.ullAvailPhys/one_kilo;
        /* we are really erring on the safe side here :-) */
        if (available_kilos<=ULONG_MAX)
            result = (unsigned long)available_kilos;
    }

    return result;
}
开发者ID:thomas-maeder,项目名称:popeye,代码行数:21,代码来源:maxmem.c

示例9: GetRamInfo

RamInfo GetRamInfo()
{
	static Cache<RamInfo> Value;

	return Value.Get([]() 
	{
		MEMORYSTATUSEX MemInfo;
		MemInfo.dwLength = sizeof(MEMORYSTATUSEX);
		GlobalMemoryStatusEx(&MemInfo);

		RamInfo Info;
		Info.TotalPhysicalRam = MemInfo.ullTotalPhys;
		Info.TotalVirtualRam = MemInfo.ullTotalVirtual;
		Info.TotalPageRam = MemInfo.ullTotalPageFile;

		return Info;
	});
}
开发者ID:TLeonardUK,项目名称:Ludo,代码行数:18,代码来源:Environment.cpp

示例10: meminfo_totalram

/**
 * @file
 * @brief 
 * Total Ram
 *
 * @details
 * This function looks up the total ram in bytes.
 *
 * @param totalram
 * Output, passed by reference.  On successful return, the value
 * is set to the total ram (in bytes) available on the system.
 *
 * @return
 * The return value indicates the status of the function.
 */
int meminfo_totalram(memsize_t *totalram)
{
  int ret = MEMINFO_OK;
  *totalram = 0L;
  
  
#if OS_LINUX
  struct sysinfo info;
  int test = sysinfo(&info);
  chkret(test, FAILURE);
  
  *totalram = (memsize_t) info.totalram * info.mem_unit;
#elif OS_MAC
  int test = sysctl_val("hw.memsize", totalram);
  chkret(test, FAILURE);
#elif OS_WINDOWS
  MEMORYSTATUSEX status;
  status.dwLength = sizeof(status);
  
  int test = GlobalMemoryStatusEx(&status);
  winchkret(test, FAILURE);
  
  *totalram = (memsize_t) status.ullTotalPhys;
#elif OS_FREEBSD
  int test = sysctl_val("hw.physmem", totalram);
  chkret(test, FAILURE);
#elif OS_NIX
  memsize_t npages, pagesize;
  
  npages = sysconf(_SC_PHYS_PAGES);
  if (npages == FAILURE)
    return FAILURE;
  
  pagesize = sysconf(_SC_PAGESIZE);
  if (pagesize == FAILURE)
    return FAILURE;
  
  *totalram = (memsize_t) npages * pagesize;
#else
  ret = PLATFORM_ERROR;
#endif
  
  return ret;
}
开发者ID:cran,项目名称:memuse,代码行数:59,代码来源:raminfo.c

示例11: swap_free_func

/* FIXME: should be using PERFORMANCE_INFORMATION.CommitTotal */
g_val_t
swap_free_func ( void )
{
   MEMORYSTATUSEX stat;
   DWORDLONG size;
   g_val_t val;

   stat.dwLength = sizeof(stat);

   if ( GlobalMemoryStatusEx (&stat)) {
      size = stat.ullAvailPageFile;
      /* get the value in kB */
      val.f =  size / 1024;
   } else {
      val.f = 0;
   }

   return val;
}
开发者ID:colama,项目名称:colama-3rdparty-tools,代码行数:20,代码来源:metrics.c

示例12: GetAvailableMemory

//*****************************************************************************
INT64 GetAvailableMemory()
{
#ifdef _WIN32
    // Size of available memory in bytes, with an additional
    // 200Mb subtracted to take into account heap fragmentation,
    // and a 100Mb buffer for smaller allocations that may happen in
    // between checks.
    MEMORYSTATUSEX  statex;
    statex.dwLength = sizeof (statex);
    INT64 maxAvailable = 0L;
    if(GlobalMemoryStatusEx (&statex)) {
        maxAvailable = min(statex.ullAvailPhys + statex.ullAvailPageFile, statex.ullAvailVirtual);
        maxAvailable = (maxAvailable > 300000000L) ? maxAvailable - 300000000L : 0L;
    }
    return maxAvailable;
#else // LINUX
    throw new MgNotImplementedException(L"GetAvailableMemory", __LINE__, __WFILE__, NULL, L"", NULL);
#endif
}
开发者ID:asir6,项目名称:Colt,代码行数:20,代码来源:CoordSysUtil.cpp

示例13: meminfo_gettext

static int meminfo_gettext(int tag, char *buf)
{
	MEMORYSTATUSEX memory;
	memory.dwLength = sizeof(memory);
	GlobalMemoryStatusEx(&memory);
	return ksprintf(buf,
		"MemTotal:  %13llu kB\n"
		"MemFree:   %13llu kB\n"
		"HighTotal: %13llu kB\n"
		"HighFree:  %13llu kB\n"
		"LowTotal:  %13llu kB\n"
		"LowFree:   %13llu kB\n"
		"SwapTotal: %13llu kB\n"
		"SwapFree:  %13llu kB\n",
		memory.ullTotalPhys / 1024ULL, memory.ullAvailPhys / 1024ULL,
		0ULL, 0ULL,
		memory.ullTotalPhys / 1024ULL, memory.ullAvailPhys / 1024ULL,
		memory.ullTotalPageFile / 1024ULL, memory.ullAvailPageFile / 1024ULL);
}
开发者ID:AnXi-TieGuanYin-Tea,项目名称:flinux,代码行数:19,代码来源:procfs.c

示例14: dep_initialize

/**
 * @brief
 *      Called from machine independent code to do any machine
 *      dependent initialization.
 *
 * @return      Void
 *
 */
void
dep_initialize()
{
	MEMORYSTATUSEX		mse;
	SYSTEM_INFO		si;

	mse.dwLength = sizeof(MEMORYSTATUSEX);
	GlobalMemoryStatusEx(&mse);
	pmem_size = mse.ullTotalPhys / 1024;

	GetSystemInfo(&si);
	num_acpus = num_oscpus = num_pcpus = si.dwNumberOfProcessors;
	page_size = si.dwPageSize;

	if (!init_profile("\\System\\Processor Queue Length", &mom_prof)) {
		log_err(-1, "dep_initialize", "init_profile failed!");
		return;
	}
}
开发者ID:A9-William,项目名称:pbspro,代码行数:27,代码来源:mom_mach.c

示例15: ustring_GlobalMemoryStatus

int ustring_GlobalMemoryStatus(lua_State *L)
{
	MEMORYSTATUSEX ms;
	ms.dwLength = sizeof(ms);

	if(0 == GlobalMemoryStatusEx(&ms))
		return SysErrorReturn(L);

	lua_createtable(L, 0, 8);
	PutNumToTable(L, "MemoryLoad",           ms.dwMemoryLoad);
	PutNumToTable(L, "TotalPhys",            CAST(double, ms.ullTotalPhys));
	PutNumToTable(L, "AvailPhys",            CAST(double, ms.ullAvailPhys));
	PutNumToTable(L, "TotalPageFile",        CAST(double, ms.ullTotalPageFile));
	PutNumToTable(L, "AvailPageFile",        CAST(double, ms.ullAvailPageFile));
	PutNumToTable(L, "TotalVirtual",         CAST(double, ms.ullTotalVirtual));
	PutNumToTable(L, "AvailVirtual",         CAST(double, ms.ullAvailVirtual));
	PutNumToTable(L, "AvailExtendedVirtual", CAST(double, ms.ullAvailExtendedVirtual));
	return 1;
}
开发者ID:FarGroup,项目名称:FarManager,代码行数:19,代码来源:ustring.c


注:本文中的GlobalMemoryStatusEx函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。