merging revisions 28564-28569 from render branch into trunk

This commit is contained in:
Joseph Eagar
2010-05-04 12:31:24 +00:00
parent cef3e3099a
commit a7cbd5008e
15 changed files with 328 additions and 89 deletions

View File

@@ -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

View File

@@ -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;