What exactly is memory usage? (was:When is it time for a 1.0 feature freeze?)

Serg Kovrov kovrov at no.spam
Sun Sep 3 13:50:25 PDT 2006


Walter Bright wrote:
> Serg Kovrov wrote:
>> I just tried simplest example with GCC(mingw): I allocated with 'new' 
>> 1Mb string. Then in process explorer (or in FAR's Process list) I can 
>> see my process usage of 'Private bytes' increases equivalently. When 
>> free this string, with 'delete', i see that 'Private bytes' usage 
>> dropped to same level it was before. Isn't this mean that memory 
>> returned to OS?
> 
> Not necessarily. There's a difference between physical memory and 
> virtual memory. The OS will automatically take away from the process any 
> unused physical memory, although the process retains it as virtual 
> memory. If the process explorer watches physical memory, then that's 
> what it's seeing.

I'm not trying to argue here, but to understand. I done some search on 
subject of memory usage. So far, I see it as I described before - to 
measure application's memory usage, best way is to watch 'private bytes' 
counter in Perfmon (or via other tools that (I believe) uses Perfmon, 
such as Process Explorer or FAR's Process list plugin).

For example, quote from http://shsc.info/WindowsMemoryManagement:
> ... is what's called "private bytes" by the Performance control panel.
> It's memory that's private to that process; generally it's the amount
> of RAM the process has asked for in order to store runtime data.

And as I said before C++'s 'delete' (not sure about all implementations, 
but at least GCC/mingw and VC++2005) do free memory from this 'private 
bytes' thing.

You said it is not really returned to OS, but get in to some pool. Ok, 
could you explain further, is it my application's pool, or some shared pool?

What I mean, is: my application allocated and used this memory, but not 
anymore - it has been 'delete'd. Application will not need a new memory 
from OS for some time, or even possibly never. Can this freed(deleted) 
memory be used elsewhere? Please note, I talking about mentioned here 
C++ implementation that actually affect 'private bytes' counter.

Thanks
-- 
serg.



More information about the Digitalmars-d mailing list