diff options
author | Ton Roosendaal <ton@blender.org> | 2006-02-16 20:51:01 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-02-16 20:51:01 +0300 |
commit | fe036a0538860bf4f0b8e87d70046ff2a75f5f28 (patch) | |
tree | c6838cde34a609ea4832b98303c683fe90fd3edd /source/blender/src/header_info.c | |
parent | 7f4b01ccf076998cac98c52aa6701f35e1c2500f (diff) |
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.
Diffstat (limited to 'source/blender/src/header_info.c')
-rw-r--r-- | source/blender/src/header_info.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 15ebfe0109f..06d75d1ab0d 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -1729,15 +1729,20 @@ static void info_text(int x, int y) { Object *ob= OBACT; extern float hashvectf[]; - extern int mem_in_use; + extern unsigned long mem_in_use, mmap_in_use; unsigned int swatch_color; float fac1, fac2, fac3; - char infostr[300]; - char *headerstr; + char infostr[300], memstr[64]; + char *headerstr, *s; int hsize; + s= memstr + sprintf(memstr," | Mem:%.2fM ", ((mem_in_use-mmap_in_use)>>10)/1024.0); + if(mmap_in_use) + sprintf(s,"(%.2fM) ", ((mmap_in_use)>>10)/1024.0); + + if(G.obedit) { - char *s = infostr; + s = infostr; s+= sprintf(s, "%s", G.editModeTitleExtra); if(G.obedit->type==OB_MESH) { @@ -1757,15 +1762,15 @@ static void info_text(int x, int y) s+= sprintf(s,"Ve:%d-%d", G.totvertsel, G.totvert); } - sprintf(s," | Mem:%.2fM ", (mem_in_use>>10)/1024.0); + strcat(s, memstr); } else if(ob && (ob->flag & OB_POSEMODE)) { - sprintf(infostr,"Bo:%d-%d | Mem:%.2fM ", - G.totbonesel, G.totbone, (mem_in_use>>10)/1024.0); + sprintf(infostr,"Bo:%d-%d %s", + G.totbonesel, G.totbone, memstr); } else { - sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d | Mem:%.2fM | Time:%s | ", - G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp, (mem_in_use>>10)/1024.0, info_time_str); + sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d %s | Time:%s | ", + G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp, memstr, info_time_str); } if(ob) { strcat(infostr, ob->id.name+2); |