Re: Memory management terminology

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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


.



Relevant Pages

  • Re: memory fragmentation, Suse Linux 64b
    ... Consider this small program, allocating a number of 100,000 Bytes memory ... topical there either since it is really a linux question ... then before the next alloc the list of free blocks will look like this ...
    (comp.lang.c)
  • Re: the different between aaa m1[100] and aaa *p = new [100]
    ... it has to find an appropriate block of memory. ... know what the glibc version of malloc uses, ... This means that it looks through a list of free blocks ... it of free blocks, and allocates memory. ...
    (comp.lang.cpp)
  • Re: Memory management terminology
    ... a range of pages is a larger chunk of memory than a single ... For a page that does not have physical backing before the ... always immediately coalesce these two free blocks into one free ... You are confusing OS memory manager and CRT heap manager. ...
    (microsoft.public.vc.language)
  • Re: FastMM (and others) feature suggestion
    ... I'm losing my hair fighting that ... > overrun here:( ... but some of the benchmarks still run out of memory (because I never ... combine adjacent free blocks in "FullDebugMode"). ...
    (borland.public.delphi.language.basm)
  • Re: Mem_Alloc and memory pointers
    ... >>> memory as the draw files could be from a few k to megabytes, ... >>> would not be good to simply grab the memory on start up, ... >> 2) Claim a dynamic area and create your sliding heap manager there. ... > WimpSlot if it needs more stack space/malloc heap. ...
    (comp.sys.acorn.programmer)