Domanda

I found the following sentence in a book :

Whenever the heap manager runs out of committed space in the heap segment, it explicitly commits more memory and divides the newly committed space into blocks as more and more allocations are requested

Does this mean when a block is allocated in the segment the virtual memory used by the user and the metadata isn't considered committed anymore ?

È stato utile?

Soluzione

This is from the advanced windows debugging book I take it, not sure what you mean as you get kind of vague towards the end, however what it basically means is as follows:

When you allocate heap space the contents of the heap are not necessarily pre-determined, so you can use that allocated space as you see fit: for example, I allocate 1 megabyte of heap memory, and I then decide to populate that space with only 512k or data, that would mean I have committed half of my allocated heap, leaving a further 512k free. That memory will still show as being utilised to the OS because I have explicitly set the heap allocation to 1024k, however next time I use that same space I could use more or less than the 512k I utilised last time, up to the amount I have allocated for use. The amount you use at a given point is the commit, the amount you have set aside is the allocation.

This is all much much simplified, and I would recommend reading such sources as:

As good sources to get you started on memory and its usage in C++.

If there is anything specific or more detail you can think of (your question is a bit unclear) then let me know and I will get back to you as soon as possible.

Altri suggerimenti

No. Allocated blocks are part of committed memory.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top