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)
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)
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
INLINE_CFLAGS=`echo $ac_n "$CFLAGS $ac_c" | sed s/-O[0-9s]*//`
#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);
}
#if MEMORY_LIMIT
AG(allocated_memory) -= SIZE;
#endif
+#if MEMORY_USAGE_INFO
+ AG(cur_allocated_memory) -= SIZE;
+#endif
free(p);
HANDLE_UNBLOCK_INTERRUPTIONS();
#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();
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)));
#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 {
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 */