[Interest] memory fragmentation?

Thiago Macieira thiago.macieira at intel.com
Thu Aug 23 10:08:18 CEST 2012


On quarta-feira, 22 de agosto de 2012 17.09.21, Alex Malyushytskyy wrote:
> For example: assume you need  1 GB for a single array, and all other
> data can't grow beyond total 500 MB.
> First thing you can do - reserve 1 GB the earliest possible, and let
> other allocation happen normally.
> Application will not allocate this memory until you commit it.
> You want to load 50MB file into this memory. Commit 50 MB,
> You want to load another file which uses 150MB. Commit extra 100 MB.
> Address space  is continues, physically no memory re-allocation
> occurs, pointers are kept valid.
> You do not care how 3rd party components (like dlls) do memory allocation.
> 
> Anyway thanks for comments, I might try to play with custom allocator
> and custom allocator using sbrk() as you suggested

On Linux, you wouldn't allocate 1 GB of memory with sbrk. You'd use an 
anonymous mmap, which reserves address space but provides no memory backing. 
The allocation is done on faulting the page.

That's how glibc's malloc() serves allocations above a certain adaptive 
threshold.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120823/75cc5169/attachment.sig>


More information about the Interest mailing list