Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2010-05-04 16:31:24 +0400
committerJoseph Eagar <joeedh@gmail.com>2010-05-04 16:31:24 +0400
commita7cbd5008e830224e73e2e55f89d0783ded422e5 (patch)
tree63f8d80c1db62e0a8f71db6d89de9d95e4b91fa0 /intern/guardedalloc
parentcef3e3099a8d808474237e26cf373b3943897cb3 (diff)
merging revisions 28564-28569 from render branch into trunk
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h6
-rw-r--r--intern/guardedalloc/intern/mallocn.c23
2 files changed, 28 insertions, 1 deletions
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index 705f099ab63..c51e96f04b5 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -144,6 +144,12 @@ extern "C" {
uintptr_t MEM_get_mapped_memory_in_use(void);
int MEM_get_memory_blocks_in_use(void);
+ /*reset the peak memory statistic to zero*/
+ void MEM_reset_peak_memory(void);
+
+ /*get the peak memory usage in bytes, including mmap allocations*/
+ uintptr_t MEM_get_peak_memory(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index 9f2f57e119c..09f2d33a674 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -138,7 +138,7 @@ static const char *check_memlist(MemHead *memh);
static volatile int totblock= 0;
-static volatile uintptr_t mem_in_use= 0, mmap_in_use= 0;
+static volatile uintptr_t mem_in_use= 0, mmap_in_use= 0, peak_mem = 0;
static volatile struct localListBase _membase;
static volatile struct localListBase *membase = &_membase;
@@ -293,6 +293,8 @@ static void make_memhead_header(MemHead *memh, size_t len, const char *str)
totblock++;
mem_in_use += len;
+
+ peak_mem = mem_in_use > peak_mem ? mem_in_use : peak_mem;
}
void *MEM_mallocN(size_t len, const char *str)
@@ -377,6 +379,7 @@ void *MEM_mapallocN(size_t len, const char *str)
make_memhead_header(memh, len, str);
memh->mmap= 1;
mmap_in_use += len;
+ peak_mem = mmap_in_use > peak_mem ? mmap_in_use : peak_mem;
mem_unlock_thread();
#ifdef DEBUG_MEMCOUNTER
if(_mallocn_count==DEBUG_MEMCOUNTER_ERROR_VAL)
@@ -802,6 +805,24 @@ static const char *check_memlist(MemHead *memh)
return(name);
}
+uintptr_t MEM_get_peak_memory(void)
+{
+ uintptr_t _peak_mem;
+
+ mem_lock_thread();
+ _peak_mem = peak_mem;
+ mem_unlock_thread();
+
+ return _peak_mem;
+}
+
+void MEM_reset_peak_memory(void)
+{
+ mem_lock_thread();
+ peak_mem = 0;
+ mem_unlock_thread();
+}
+
uintptr_t MEM_get_memory_in_use(void)
{
uintptr_t _mem_in_use;