From 7866f02260bcab3c25ba76a0c7fd7af5cd6d5c35 Mon Sep 17 00:00:00 2001 From: Andrey Hristov Date: Tue, 14 Jan 2003 18:26:47 +0000 Subject: [PATCH] added function get_memory_usage(). available only when PHP is compiled with --enable-memory-limit --- ext/standard/basic_functions.c | 3 +++ ext/standard/php_var.h | 3 +++ ext/standard/var.c | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index bd90f3b287..68cf56964d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -544,6 +544,9 @@ function_entry basic_functions[] = { PHP_FE(var_export, NULL) PHP_FE(debug_zval_dump, NULL) PHP_FE(print_r, NULL) +#if MEMORY_LIMIT + PHP_FE(get_memory_usage, NULL) +#endif PHP_FE(register_shutdown_function, NULL) PHP_FE(register_tick_function, NULL) diff --git a/ext/standard/php_var.h b/ext/standard/php_var.h index 796e1a19e3..f399a236bf 100644 --- a/ext/standard/php_var.h +++ b/ext/standard/php_var.h @@ -28,6 +28,9 @@ PHP_FUNCTION(var_export); PHP_FUNCTION(debug_zval_dump); PHP_FUNCTION(serialize); PHP_FUNCTION(unserialize); +#if MEMORY_LIMIT +PHP_FUNCTION(get_memory_usage); +#endif void php_var_dump(zval **struc, int level TSRMLS_DC); void php_var_export(zval **struc, int level TSRMLS_DC); diff --git a/ext/standard/var.c b/ext/standard/var.c index 4b5c7dc5d8..e68a5a5400 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -677,6 +677,15 @@ PHP_FUNCTION(unserialize) /* }}} */ +#if MEMORY_LIMIT +/* {{{ proto int get_memory_usage() + Returns the allocated by PHP memory */ +PHP_FUNCTION(get_memory_usage) { + RETURN_LONG(AG(allocated_memory)); +} +/* }}} */ +#endif + /* * Local variables: * tab-width: 4 -- 2.50.1