[Bf-blender-cvs] [00133ba] master: Subsurf: Use guarded allocator for non-arena CCG

Sergey Sharybin noreply at git.blender.org
Mon Feb 16 23:42:25 CET 2015


Commit: 00133ba8f098fece41c4f358a57c7ba323214502
Author: Sergey Sharybin
Date:   Tue Feb 17 03:37:14 2015 +0500
Branches: master
https://developer.blender.org/rB00133ba8f098fece41c4f358a57c7ba323214502

Subsurf: Use guarded allocator for non-arena CCG

Our new guarded allocator implementation has much smaller memory
block size overhead and doesn't have any locks now. So in order
to make fuller track of what's happening in blender and avoid
confusion why certain circumstances reports much less memory than
others we'll now switch to guarded allocator.

This was actually one of the biggest reasons of the confusion in
the recent memory usage investigation. There's still some overhead
is happening due to non-freeing nature of arena allocator but the
things are not nearly as bad as they looked before: memory overhead
is measured in tens of megabytes, not hundreds as it looked before.

Plus with some smarter allocation policy we can almost eliminate this
overhead.

===================================================================

M	source/blender/blenkernel/intern/CCGSubSurf.c

===================================================================

diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 9e5d4af..651979c 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -213,15 +213,15 @@ static int _ehashIterator_isStopped(EHashIterator *ehi)
 
 static void *_stdAllocator_alloc(CCGAllocatorHDL UNUSED(a), int numBytes)
 {
-	return malloc(numBytes);
+	return MEM_mallocN(numBytes, "CCG standard alloc");
 }
 static void *_stdAllocator_realloc(CCGAllocatorHDL UNUSED(a), void *ptr, int newSize, int UNUSED(oldSize))
 {
-	return realloc(ptr, newSize);
+	return MEM_reallocN(ptr, newSize);
 }
 static void _stdAllocator_free(CCGAllocatorHDL UNUSED(a), void *ptr)
 {
-	free(ptr);
+	MEM_freeN(ptr);
 }
 
 static CCGAllocatorIFC *_getStandardAllocatorIFC(void)




More information about the Bf-blender-cvs mailing list