Re: Memory management terminology
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Thu, 15 Jun 2006 17:52:49 -0400
better_cs_now@xxxxxxxxx wrote:
4. Committing / uncommitting is an operation that is always performed
on a page, not on any smaller or larger chunk of memory.
Well, you can commit/uncommit a range of pages with a single API call.
Technically, a range of pages is a larger chunk of memory than a single
page.
6. Memory allocated with a single call to new / malloc may all reside
in one page or, in the general case, will span multiple pages. Any of
these pages may or may not have physical backing before the
allocation. For a page that does not have physical backing before the
allocation, I believe the following can be said: That page either may
or may not be given physical backing as the result of the allocation.
If it is not given physical backing as a result of the allocation, it
will receive physical backing whenever it is first touched.
I don't think it's correct. Memory is committed at allocation. There are
techniques to implement "commit on touch" but they are not used by the
stock heap manager.
Now, I'd also like to ask a couple of questions:
1. Let's suppose that I call delete / free on a block of memory and
that that block of memory is adjacent to a free block. Now, we've got
two free blocks side-by-side. Does the Windows XP memory manager
always immediately coalesce these two free blocks into one free
block?
You are confusing OS memory manager and CRT heap manager. OS provides
manipulation at page level (see VirtualAlloc et al). CRT implements
malloc/new on top of that. OS heap (see HeapAlloc et al) is somewhat in
between in that it is implemented by the OS, but is a high-level API on
top of VirtualAlloc and friends.
Yes, a typical implementation of heap manager would coalesce two
adjacent free blocks, otherwise the heap would get fragmented very
quickly.
2. Is there a succint way to describe the algorithm that determines
when unused pages lose their physical backing?
It's not documented. You can force the issue with _heapmin or
HeapCompact.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: Memory management terminology
- From: better_cs_now@xxxxxxxxx
- Re: Memory management terminology
- References:
- Memory management terminology
- From: better_cs_now@xxxxxxxxx
- Memory management terminology
- Prev by Date: Memory management terminology
- Next by Date: Re: Memory management terminology
- Previous by thread: Memory management terminology
- Next by thread: Re: Memory management terminology
- Index(es):
Relevant Pages
|