There are at least 3 ways of measuring memory consumption:
- virtual address space - the amount of your process's address space consumed by the allocation. this also affects fragmentation and the maximum contiguous future allocations you can make.
- commit charge - this is the operating system's accounting of the maximum possible physical storage required to maintain all of the writable, non-file/device-backed memory allocated to your process. if the OS allows it to exceed the total physical memory + swap, very bad things could happen the first time the excess is written to.
- physical memory - the amount of physical resources (potentially including swap, depending on your interpretation) your process is currently occupying. This could be less than commit charge due to virgin zero pages and virgin private writable maps of files, or more than commit charge due to non-writable or shared mappings the process is using (but these are usually swappable/discardable).
malloc generally affects them all.
Edit: So, the best way I can think to answer your question is to say:
malloc allocates virtual memory.
And virtual memory consumes:
- virtual address space,
- commit charge, and
- physical resources, if it's been written to.