summaryrefslogtreecommitdiff
path: root/Zend/zend_alloc.c
diff options
context:
space:
mode:
authorThies C. Arntzen <thies@php.net>2001-05-11 18:16:41 +0000
committerThies C. Arntzen <thies@php.net>2001-05-11 18:16:41 +0000
commit8ca106bffc2ea5d7db082d3db5b7b27d800c748e (patch)
tree042d0832cae2d331812a82a96845d9d4cba1b4c2 /Zend/zend_alloc.c
parent78c8a877f8ad9b27a1c3654a0fa48a8f0862c04e (diff)
downloadphp-git-8ca106bffc2ea5d7db082d3db5b7b27d800c748e.tar.gz
added --enable-memory-usage-info
Diffstat (limited to 'Zend/zend_alloc.c')
-rw-r--r--Zend/zend_alloc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index ade2d03c31..7a70333ea9 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -185,6 +185,12 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#if MEMORY_LIMIT
CHECK_MEMORY_LIMIT(size, SIZE);
#endif
+#if MEMORY_USAGE_INFO
+ AG(cur_allocated_memory) += SIZE;
+ if (AG(cur_allocated_memory) > AG(max_allocated_memory))
+ AG(max_allocated_memory) = AG(cur_allocated_memory);
+#endif
+
HANDLE_UNBLOCK_INTERRUPTIONS();
return (void *)((char *)p + sizeof(zend_mem_header) + MEM_HEADER_PADDING);
}
@@ -228,6 +234,9 @@ ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
#if MEMORY_LIMIT
AG(allocated_memory) -= SIZE;
#endif
+#if MEMORY_USAGE_INFO
+ AG(cur_allocated_memory) -= SIZE;
+#endif
free(p);
HANDLE_UNBLOCK_INTERRUPTIONS();
@@ -305,6 +314,12 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN
#if MEMORY_LIMIT
CHECK_MEMORY_LIMIT(size - p->size, SIZE - REAL_SIZE(p->size));
#endif
+#if MEMORY_USAGE_INFO
+ AG(cur_allocated_memory) += SIZE - REAL_SIZE(p->size);
+ if (AG(cur_allocated_memory) > AG(max_allocated_memory))
+ AG(max_allocated_memory) = AG(cur_allocated_memory);
+#endif
+
p->size = size;
HANDLE_UNBLOCK_INTERRUPTIONS();
@@ -390,6 +405,10 @@ ZEND_API void start_memory_manager(ALS_D)
AG(allocated_memory) = 0;
AG(memory_exhausted) = 0;
#endif
+#if MEMORY_USAGE_INFO
+ AG(cur_allocated_memory) = 0;
+ AG(max_allocated_memory) = 0;
+#endif
memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head)));
memset(AG(cache_count), 0, sizeof(AG(cache_count)));
@@ -488,6 +507,10 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
#if MEMORY_LIMIT
AG(memory_exhausted)=0;
#endif
+#if MEMORY_USAGE_INFO
+ AG(cur_allocated_memory) = 0;
+ AG(max_allocated_memory) = 0;
+#endif
#if (ZEND_DEBUG)
do {