From 260b4d0dbf7ab775be6dff25b977e206fbd66b8f Mon Sep 17 00:00:00 2001 From: Zeev Suraski Date: Wed, 16 May 2001 15:02:30 +0000 Subject: [PATCH] Merge memory usage into memory limit --- Zend/Zend.m4 | 16 ---------------- Zend/zend_alloc.c | 28 +++++++--------------------- Zend/zend_globals.h | 4 ---- sapi/apache/mod_php4.c | 4 ++-- 4 files changed, 9 insertions(+), 43 deletions(-) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index 360c50d009..2efe422af1 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -123,13 +123,6 @@ AC_ARG_ENABLE(memory-limit, ZEND_MEMORY_LIMIT=no ]) -AC_ARG_ENABLE(memory-usage-info, -[ --enable-memory-usage-info Compile with support for memory usage info. ], [ - ZEND_MEMORY_USAGE_INFO=$enableval -],[ - ZEND_MEMORY_USAGE_INFO=no -]) - AC_MSG_CHECKING(whether to enable experimental ZTS) AC_MSG_RESULT($ZEND_EXPERIMENTAL_ZTS) @@ -139,9 +132,6 @@ AC_MSG_RESULT($ZEND_INLINE_OPTIMIZATION) AC_MSG_CHECKING(whether to enable a memory limit) AC_MSG_RESULT($ZEND_MEMORY_LIMIT) -AC_MSG_CHECKING(whether to enable a memory usage) -AC_MSG_RESULT($ZEND_MEMORY_USAGE_INFO) - AC_MSG_CHECKING(whether to enable Zend debugging) AC_MSG_RESULT($ZEND_DEBUG) @@ -177,12 +167,6 @@ else AC_DEFINE(MEMORY_LIMIT, 0, [Memory limit]) fi -if test "$ZEND_MEMORY_USAGE_INFO" = "yes"; then - AC_DEFINE(MEMORY_USAGE_INFO, 1, [Memory usage]) -else - AC_DEFINE(MEMORY_USAGE_INFO, 0, [Memory usage]) -fi - changequote({,}) if test -n "$GCC" && test "$ZEND_INLINE_OPTIMIZATION" != "yes"; then diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 7a70333ea9..488a2c0ec4 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -184,11 +184,9 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) #endif #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); + if (AG(allocated_memory) > AG(allocated_memory_peak) { + AG(allocated_memory_peak) = AG(allocated_memory); + } #endif HANDLE_UNBLOCK_INTERRUPTIONS(); @@ -234,9 +232,6 @@ 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(); @@ -313,11 +308,8 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LIN #endif #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); + if (AG(allocated_memory) > AG(allocated_memory_peak)) { + AG(allocated_memory_peak) = AG(allocated_memory); #endif p->size = size; @@ -404,10 +396,7 @@ ZEND_API void start_memory_manager(ALS_D) AG(memory_limit) = 1<<30; /* rediculous limit, effectively no limit */ AG(allocated_memory) = 0; AG(memory_exhausted) = 0; -#endif -#if MEMORY_USAGE_INFO - AG(cur_allocated_memory) = 0; - AG(max_allocated_memory) = 0; + AG(allocated_memory_peak) = 0; #endif memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head))); @@ -507,10 +496,7 @@ 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 { diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index b853800c56..867fee8316 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -217,10 +217,6 @@ struct _zend_alloc_globals { unsigned int allocated_memory; unsigned char memory_exhausted; #endif -#if MEMORY_USAGE_INFO - unsigned int cur_allocated_memory; - unsigned int max_allocated_memory; -#endif }; #endif /* ZEND_GLOBALS_H */ diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c index a43f34ba12..0a83324c05 100644 --- a/sapi/apache/mod_php4.c +++ b/sapi/apache/mod_php4.c @@ -546,12 +546,12 @@ static int send_parsed_php(request_rec * r) { int result = send_php(r, 0, NULL); -#if MEMORY_USAGE_INFO +#if MEMORY_LIMIT { char mem_usage[ 32 ]; ALS_FETCH() - sprintf(mem_usage,"%u", (int) AG(max_allocated_memory)); + sprintf(mem_usage,"%u", (int) AG(allocated_memory_peak)); ap_table_setn(r->notes, "mod_php_memory_usage", ap_pstrdup(r->pool,mem_usage)); } #endif -- 2.50.1