[Bf-blender-cvs] CVS commit: blender/intern/guardedalloc MEM_guardedalloc.h blender/intern/guardedalloc/intern mallocn.c

Ton Roosendaal ton at blender.org
Thu Feb 16 18:51:01 CET 2006


ton (Ton Roosendaal) 2006/02/16 18:51:01 CET

  Modified files:
    blender/intern/guardedalloc MEM_guardedalloc.h 
    blender/intern/guardedalloc/intern mallocn.c 
  
  Log:
  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.
  
  Revision  Changes    Path
  1.7       +11 -6     blender/intern/guardedalloc/MEM_guardedalloc.h
    <http://projects.blender.org/viewcvs/viewcvs.cgi/blender/intern/guardedalloc/MEM_guardedalloc.h.diff?r1=1.6&r2=1.7&cvsroot=bf-blender>
  1.10      +89 -60    blender/intern/guardedalloc/intern/mallocn.c
    <http://projects.blender.org/viewcvs/viewcvs.cgi/blender/intern/guardedalloc/intern/mallocn.c.diff?r1=1.9&r2=1.10&cvsroot=bf-blender>



More information about the Bf-blender-cvs mailing list