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

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to