Re: GC performance - GC fragility



Andre Kaufmann wrote:

The point you are missing, that it's still a linear address space, or
isn't the address space each process has 2 GB linear ? Isn't the
whole process and the system using virtual memory ? Isn't GC >not
using< virtual memory ?

In a virtual block of memory and free the 3 bytes and 4 bytes and
want to allocate 8 bytes, the hole inside this "virtual memory" block
can't be used or filled by a native heap. No way.


Welllll.... actually, it's not quite that simple. When you allocate
memory, you allocate two separate things from the operating system:

1. Virtual Address space.
2. Physical storage.

The point is that when it comes to doing things like a re-alloc, since
you're allowing the address to be changed, the OS can change the
virtual address of the memory, and hence the apparent location, without
doing any actual memory copying, simply by changing the page tables.

This means that in some cases you can reduce fragementation. e.g:

In virtual address space:

1M allocated, 1M free, 1M allocated, 1M free. 1M allocated.

Now lets say that you realloc the middle 1M to 512K.

If you ask the OS to do that (and not a subsidiary heap), there's
nothing to stop it remapping the pages so that you end up with:

1M allocated, 3M Free, 1M Allocated, 512K allocated.

Admittedly, everything is "modulo page size", but the point is that
fragmentation for quantities bigger than a page size is still *virtual
fragementation*.

MH.
.



Relevant Pages

  • Re: memory leak
    ... MSFT have already said that they will fix this problem, ... What is your definition of "video RAM"? ... You could try to allocate and have it throw if you're out of virtual memory. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Windows array allocation problem
    ... I'm getting an "insufficient virtual memory" error when trying to allocate an array to a size which is about 385 MB less than the amount of available virtual memory. ...
    (comp.lang.fortran)
  • Re: Windows array allocation problem
    ... allocate an array to a size which is about 385 MB less than the amount of available virtual memory. ... In both cases a call to Windows API function GlobalMemoryStatus or GlobalMemoryStatusEx immediately before the ALLOCATE statement returns a value of available virtual memory of 2,118,221,824 bytes. ... So I'm getting an "insufficient virtual memory" failure when trying to allocate the array to a size which is 384.665 MB less than the amount of reported available virtual memory. ...
    (comp.lang.fortran)
  • Re: Windows array allocation problem
    ... allocate an array to a size which is about 385 MB less than the amount of available virtual memory. ... In both cases a call to Windows API function GlobalMemoryStatus or GlobalMemoryStatusEx immediately before the ALLOCATE statement returns a value of available virtual memory of 2,118,221,824 bytes. ... So I'm getting an "insufficient virtual memory" failure when trying to allocate the array to a size which is 384.665 MB less than the amount of reported available virtual memory. ...
    (comp.lang.fortran)
  • Re: virtual memory leak? in asp.net app - OutOfMemory exception
    ... Doing so seems to allocate several hundred MBs of ... Loading the same XML stream again seems to re-use the allocated virtual ... Why is the app not releasing the virtual memory as it reaches is memory ...
    (microsoft.public.dotnet.framework.clr)