Blender Git Commit Log

Git Commits -> Revision fe036a0

Revision fe036a0 by Ton Roosendaal (master)
February 16, 2006, 17:51 (GMT)
Added new malloc type in our MEM module; using the unix feature 'mmap'.

In Orange we've been fighting the past weeks with memory usage a lot...
at the moment incredible huge scenes are being rendered, with multiple
layers and all compositing, stressing limits of memory a lot.
I had hoped that less frequently used blocks would be swapped away
nicely, so fragmented memory could survive. Unfortunately (in OSX) the
malloc range is limited to 2 GB only (upped half of address space).
Other OS's have a limit too, but typically larger afaik.

Now here's mmap to the rescue! It has a very nice feature to map to
a virtual (non existing) file, allowing to allocate disk-mapped memory
on the fly. For as long there's real memory it works nearly as fast as
a regular malloc, and when you go to the swap boundary, it knows nicely
what to swap first.

The upcoming commit will use mmap for all large memory blocks, like
the composit stack, render layers, lamp buffers and images. Tested here
on my 1 GB system, and compositing huge images with a total of 2.5 gig
still works acceptable here. :)

http://www.blender.org/bf/memory.jpg
This is a silly composit test, using 64 MB images with a load of nodes.
Check the header print... the (2323.33M) is the mmap disk-cache in use.

BTW: note that is still limited to the virtual address space of 4 GB.

The new call is:
MEM_mapalloc()

Per definition, mmap() returns zero'ed memory, so a calloc isn't required.

For Windows there's no mmap() available, but I'm pretty sure there's an
equivalent. Windows gurus here are invited to insert that here in code! At
the moment it's nicely ifdeffed, so for Windows the mmap defaults to a
regular alloc.

Commit Details:

Full Hash: fe036a0538860bf4f0b8e87d70046ff2a75f5f28
SVN Revision: 6840
Parent Commit: 7f4b01c
Lines Changed: +151, -101

11 Modified Paths:

/intern/guardedalloc/intern/mallocn.c (+87, -58) (Diff)
/intern/guardedalloc/MEM_guardedalloc.h (+9, -4) (Diff)
/source/blender/blenkernel/intern/node_composite.c (+8, -7) (Diff)
/source/blender/blenlib/BLI_threads.h (+1, -0) (Diff)
/source/blender/blenlib/intern/threads.c (+8, -0) (Diff)
/source/blender/imbuf/intern/allocimbuf.c (+4, -4) (Diff)
/source/blender/render/intern/source/pipeline.c (+5, -5) (Diff)
/source/blender/render/intern/source/shadbuf.c (+1, -1) (Diff)
/source/blender/render/intern/source/zbuf.c (+6, -6) (Diff)
/source/blender/src/header_info.c (+14, -9) (Diff)
/source/blender/src/renderwin.c (+8, -7) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021