⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 15.txt

📁 This complete matlab for neural network
💻 TXT
字号:
发信人: GzLi (笑梨), 信区: DataMining
标  题: [合集]要测量程序运行中使用的最大内存量,how
发信站: 南京大学小百合站 (Fri Jul 18 00:25:51 2003)

helloboy (hello) 于Wed Jun 25 08:22:41 2003)
提到:

help


minerboy (miner) 于Wed Jun 25 09:58:24 2003)
提到:

最直接的办法,打开任务管理器,用眼睛看:)
【 在 helloboy (hello) 的大作中提到: 】
: help


fervvac (高远) 于Wed Jun 25 11:17:40 2003)
提到:

reload the "new" operator if you are using C++, or use custom malloc() 
function in C

【 在 minerboy (miner) 的大作中提到: 】
: 最直接的办法,打开任务管理器,用眼睛看:)
: 【 在 helloboy (hello) 的大作中提到: 】


cczhu (congcongzhu) 于Wed Jun 25 11:58:26 2003)
提到:

真的要用这个方法?不是太好啊。听说有这样的工具,不用自己实现。


【 在 fervvac 的大作中提到: 】

: reload the "new" operator if you are using C++, or use custom malloc() 

: function in C

: 【 在 minerboy (miner) 的大作中提到: 】



finalgas (数据挖掘*为你而累) 于Wed Jun 25 18:08:14 2003)
提到:

    Please use the method in VC as follows::

    MEMORYSTATUS lpBuffer;
    GlobalMemoryStatus(&lpBuffer);
    SIZE_T dwTotalPageFile;
    SIZE_T dwAvailPageFile;
    dwTotalPageFile=lpBuffer.dwTotalPageFile;
    dwAvailPageFile=lpBuffer.dwAvailPageFile;
    DWORD AvailSize=dwTotalPageFile-dwAvailPageFile;
    fprintf(StatusFile,"当前已用内存:%d兆\n",(AvailSize/(1024*1024)));
    

【 在 helloboy (hello) 的大作中提到: 】
: help


minerboy (miner) 于Wed Jun 25 22:55:54 2003)
提到:

高手!C写的程序呢?
【 在 finalgas (数据挖掘*为你而累) 的大作中提到: 】
:     Please use the method in VC as follows::
:     MEMORYSTATUS lpBuffer;
:     GlobalMemoryStatus(&lpBuffer);
:     SIZE_T dwTotalPageFile;
:     SIZE_T dwAvailPageFile;
:     dwTotalPageFile=lpBuffer.dwTotalPageFile;
:     dwAvailPageFile=lpBuffer.dwAvailPageFile;
:     DWORD AvailSize=dwTotalPageFile-dwAvailPageFile;
:     fprintf(StatusFile,"当前已用内存:%d兆\n",(AvailSize/(1024*1024)));
: 【 在 helloboy (hello) 的大作中提到: 】


finalgas (数据挖掘*为你而累) 于Wed Jun 25 23:07:46 2003)
提到:

   下面是MSDN里的一个例子,更加详细地说明了当前物理内存,虚拟内存

的总量及使用量的获取方法:

//  Sample output:
//  c:\>global
//  The MemoryStatus structure is 32 bytes long.
//  It should be 32.
//  78 percent of memory is in use.
//  There are   65076 total Kbytes of physical memory.
//  There are   13756 free Kbytes of physical memory.
//  There are  150960 total Kbytes of paging file.
//  There are   87816 free Kbytes of paging file.
//  There are  1fff80 total Kbytes of virtual memory.
//  There are  1fe770 free Kbytes of virtual memory.
#include <windows.h>
// Use to change the divisor from Kb to Mb.
#define DIV 1024
// #define DIV 1
char *divisor = "K";
// char *divisor = "";
// Handle the width of the field in which to print numbers this way to
// make changes easier. The asterisk in the print format specifier
// "%*ld" takes an int from the argument list, and uses it to pad and
// right-justify the number being formatted.
#define WIDTH 7
void main(int argc, char *argv[])
{
  MEMORYSTATUS stat;
  GlobalMemoryStatus (&stat);
  printf ("The MemoryStatus structure is %ld bytes long.\n",
          stat.dwLength);
  printf ("It should be %d.\n", sizeof (stat));
  printf ("%ld percent of memory is in use.\n",
          stat.dwMemoryLoad);
  printf ("There are %*ld total %sbytes of physical memory.\n",
          WIDTH, stat.dwTotalPhys/DIV, divisor);
  printf ("There are %*ld free %sbytes of physical memory.\n",
          WIDTH, stat.dwAvailPhys/DIV, divisor);
  printf ("There are %*ld total %sbytes of paging file.\n",
          WIDTH, stat.dwTotalPageFile/DIV, divisor);
  printf ("There are %*ld free %sbytes of paging file.\n",
          WIDTH, stat.dwAvailPageFile/DIV, divisor);
  printf ("There are %*lx total %sbytes of virtual memory.\n",
          WIDTH, stat.dwTotalVirtual/DIV, divisor);
  printf ("There are %*lx free %sbytes of virtual memory.\n",
          WIDTH, stat.dwAvailVirtual/DIV, divisor);
}

【 在 minerboy (miner) 的大作中提到: 】
: 高手!C写的程序呢?
: 【 在 finalgas (数据挖掘*为你而累) 的大作中提到: 】


fervvac (高远) 于Thu Jun 26 11:15:03 2003)

提到:

The result obtained is the global memory usage, which is not solely 

determined by the process one wants to monitor.


starfish has posted another solution at AI board here. An equivalent

utility funciton can be found in MSDN uner the entry of :

  Collecting Memory Usage Information For a Process


To compile his program or MSDN's example:

1) download psapi.* from 

  http://d0.phys.washington.edu/Projects/l3/auto_start/building/Default.htm

2) go to project setting: add psapi.lib to the link tab.


【 在 finalgas (数据挖掘*为你而累) 的大作中提到: 】

:     Please use the method in VC as follows::

:     MEMORYSTATUS lpBuffer;

:     GlobalMemoryStatus(&lpBuffer);

:     SIZE_T dwTotalPageFile;

:     SIZE_T dwAvailPageFile;

:     dwTotalPageFile=lpBuffer.dwTotalPageFile;

:     dwAvailPageFile=lpBuffer.dwAvailPageFile;

:     DWORD AvailSize=dwTotalPageFile-dwAvailPageFile;

:     fprintf(StatusFile,"当前已用内存:%d兆\n",(AvailSize/(1024*1024)));

: 【 在 helloboy (hello) 的大作中提到: 】



GzLi (笑梨) 于Thu Jun 26 17:15:06 2003)
提到:

【 以下文字转载自 AI 讨论区 】
【 原文由 starfish 所发表 】

下面这个程序必须用VC编译,并在win2000或winXP下面运行:

编译命令行为:

cl timeit.cpp /O2 /Ob1 /Oy /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /GF

 /FD /EHsc /ML /GS /Gy /W3 /nologo /Wp64 /Zi /TP /link /OUT:"TimeIt.exe" /INCR

EMENTAL:NO /NOLOGO /DEBUG /PDB:"TimeIt.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:I

CF /MACHINE:IX86 psapi.lib  kernel32.lib


注意是一整行,你可以写在一个批处理文件中,然后执行该文件编译下面的代码。

程序执行方式是:

timeit 可执行程序名 参数1 参数2 ...


// begin of source code

// filename: timeit.cpp


#pragma once

#define WIN32_LEAN_AND_MEAN

#include <stdio.h>

#include <tchar.h>

#include <string.h>

#include <windows.h>

#include <Psapi.h>


#define BUFFER_SIZE 1000

#define UNKNOWN	   -1

#define WIN32S		0

#define WIN95		1

#define WIN98		2

#define WINNT		3

#define WIN2000		4


bool IsHelp(TCHAR* str)

{

	return (stricmp(str, "/h") == 0 ||

}


int GetSystemVersion()

{

	OSVERSIONINFOEX osvi;

}


void TimeProgram(TCHAR* cmdline)

{

    STARTUPINFO si;

    PROCESS_INFORMATION pi;

    FILETIME tCreationTime, tExitTime, tKernelTime, tUserTime;


    ZeroMemory( &si, sizeof(si) );

    si.cb = sizeof(si);

    ZeroMemory( &pi, sizeof(pi) );


    // Start the child process.

    if( !CreateProcess( NULL, // No module name (use command line).

        cmdline,    		  // Command line.

        NULL,             	  // Process handle not inheritable.

        NULL,             	  // Thread handle not inheritable.

        FALSE,                // Set handle inheritance to FALSE.

        0,                	  // No creation flags.

        NULL,             	  // Use parent's environment block.

        NULL,             	  // Use parent's starting directory.

        &si,              	  // Pointer to STARTUPINFO structure.

        &pi )             	  // Pointer to PROCESS_INFORMATION structure.

    )

    {

        printf("CreateProcess failed.\n");

        return;

    }


    // Wait until child process exits.

    WaitForSingleObject( pi.hProcess, INFINITE );


    if ( GetProcessTimes( pi.hProcess,

        &tCreationTime,

        &tExitTime,

        &tKernelTime,

        &tUserTime ) )

    {

        printf("程序运行时间:%d 毫秒\n",

        	(tKernelTime.dwLowDateTime + tUserTime.dwLowDateTime) / 10000);

    }

    


    PROCESS_MEMORY_COUNTERS pmc;


    if ( GetProcessMemoryInfo( pi.hProcess, &pmc, sizeof(pmc)) ) {

    	printf("最大内存使用:%.3f KB\n", double(pmc.PeakWorkingSetSize) / double

(1024) );              

    }        

}


int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])

{

	TCHAR cmdline[BUFFER_SIZE];

}


【 在 helloboy 的大作中提到: 】

: 【 以下文字转载自 DataMining 讨论区 】

: 【 原文由 helloboy 所发表 】

: help



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -