Click here to Skip to main content
16,004,647 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
usually, with API GetProcessMemoryInfo, I can get one process's memory size, but it is larger than what i find form windows task manager, why? how can i get the size the same with that i can find from windos task manager?
Posted

Windows Task Manager is wrong anyhow, it tells you what has been allocated. I don't see why an API would give a larger number, but I do know that Task Manager is not a useful tool for tracking memory usage.
 
Share this answer
 
Comments
gong_yanjun 6-Jul-11 7:16am    
fisrtly thanks for your answer, but i can't understand why the Windows Task Manager is wrong anyhow. except for the process memory size, are there other incorrect information ? Why does MS show some wrong information to users?
JohnCz 25-Oct-18 8:13am    
I know this is an old post but for somebody who stumbles across it: the statement about Task Manager being wrong is completely unsubstantiated. Task manager is using the same performance counters as API. Most likely statement like in above post is driven by lack of understanding what type of memory Task Manager reports.
The values in memory usage column ( in the Task Manager) equate to the application's working set, which equate to the amount of physical RAM currently allocated to the application for any use at all (it doesn't include space occupied in the paging file). Many developers like to keep an eye on their application's working set and this can be done programmatically.The Task Manager can display lots more information, the choices being available in the dialog you get from View->Select Columns... menu item. Another useful value to display is the virtual memory size of your applications (which tells you how much of the paging file your application occupies). This can also be obtained programmatically.

The source of this information is an API in the PSAPI unit, an import unit for some routines available only on NT platforms. The GetProcessMemoryInfo routine fills a TProcessMemoryCounters record with information on various aspects of your application's memory consumption. The WorkingSetSize unsurprisingly returns the current size of your working set (PeakWorkingSetSize returns the largest it has been). PagefileUsage returns the value displayed by Task Manager as the virtual memory size (PeakPagefileUsage displays the maximum it has been).
 
Share this answer
 
I get one process's memory size is larger than what find from win7's task manager, but winxp's task manager is the same.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900