The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on March 27, 2010, 07:39:18 AM

Title: Get Memory size
Post by: ragdog on March 27, 2010, 07:39:18 AM
Hello

Can i calculate the memory size of a running process

I get The baseaddr and Basesize with Module32First


   mov  ecx,hModule.modBaseAddr  ;00400000
    add  ecx,hModule.modBaseSize   ;14000
    mov [hEndOfMem],ecx              ;result  00414000

my result is 7362A265 why this?

greets
Title: Re: Get Memory size
Post by: hutch-- on March 27, 2010, 12:37:52 PM
Vaguely I remember this being a characteristic of the PE header and I gather here you are talking about the range from the start address 400000h to the end of the loaded executable module. For a DLL you will need to get the start address with GetModuleHandle().
Title: Re: Get Memory size
Post by: Slugsnack on March 27, 2010, 01:46:34 PM
show all your code. it's not making sense
Title: Re: Get Memory size
Post by: donkey on March 27, 2010, 01:57:09 PM
If you're already enumerating the process why not use GetProcessMemoryInfo ?

http://msdn.microsoft.com/en-us/library/ms683219%28VS.85%29.aspx

Also are you talking about physical or total memory, working set or actual usage, average minimum or peak usage ? Are you looking for the usage of just the main module or all modules in the process, do you want to know the heap and stack allocations as well ? When it comes to memory in Windows (or any modern OS) you have to specify exactly what usage statistic you are looking for.