CVS update: php31/main
| From: | zeev | Date: | Fri, 21 Aug 1998 00:15:29 +0000 |
| Subject: | CVS update: php31/main | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-377@lists.php.net to get a copy of this message | ||
Date: Thursday August 20, 1998 @ 20:15
Author: zeev
Update of /repository/php31/main
In directory asf:/tmp/cvs-serv18215/main
Modified Files:
alloc.c alloc.h tls.h
Log Message:
Add memory_status(), may be useful in debugging and performance tuning
Start a ChangeLog, we might as well do it now...
Index: php31/main/alloc.c
diff -c php31/main/alloc.c:2.1 php31/main/alloc.c:2.2
*** php31/main/alloc.c:2.1 Thu Aug 20 17:50:31 1998
--- php31/main/alloc.c Thu Aug 20 20:15:28 1998
***************
*** 38,43 ****
--- 38,45 ----
#include "main.h"
+ #define MAX_CACHED_MEMORY 64
+ #define MAX_CACHED_ENTRIES 16
#ifndef THREAD_SAFE
static mem_header *head;
***************
*** 371,376 ****
--- 373,418 ----
t = p;
}
GLOBAL(initialized) &= ~INIT_MEMORY_MANAGER;
+ }
+
+ void memory_manager_status(unsigned char verbose)
+ {
+ mem_header *p = GLOBAL(head);
+ uint total_memory=0, small_blocks=0, large_blocks=0;
+ int i;
+
+ while (p) {
+ if (verbose) {
+ #if DEBUG
+ if (p->filename) {
+ php3_printf("%d bytes, allocated from %s:%d<br>\n", p->size,
p->filename, p->lineno);
+ } else {
+ php3_printf("%d bytes (cached)<br>\n", p->size);
+ }
+ #else
+ php3_printf("%d bytes\n", p->size);
+ #endif
+ }
+ total_memory += p->size;
+ if (p->size > MAX_CACHED_MEMORY) {
+ large_blocks++;
+ } else {
+ small_blocks++;
+ }
+ p = p->pNext;
+ }
+ if (verbose) {
+ php3_printf("<br><br>\n\n");
+ php3_printf("Cache status:<br>\n");
+ for (i=0; i<MAX_CACHED_MEMORY; i++) {
+ if (cache_count[i]>0) {
+ php3_printf("%d bytes: %d blocks\n", i, cache_count[i]);
+ }
+ }
+ php3_printf("<br><br>\n\n");
+ }
+ php3_printf("%d bytes allocated in %d blocks (%d small blocks, %d large
blocks)<br><br>\n\n",
+ total_memory, small_blocks+large_blocks, small_blocks, large_blocks);
}
/*
Index: php31/main/alloc.h
diff -c php31/main/alloc.h:2.0 php31/main/alloc.h:2.1
*** php31/main/alloc.h:2.0 Fri Jul 3 09:17:12 1998
--- php31/main/alloc.h Thu Aug 20 20:15:28 1998
***************
*** 50,58 ****
} align_test;
- #define MAX_CACHED_MEMORY 64
- #define MAX_CACHED_ENTRIES 16
-
#define PLATFORM_ALIGNMENT (sizeof(align_test))
#define PLATFORM_PADDING
(((PLATFORM_ALIGNMENT-sizeof(mem_header))%PLATFORM_ALIGNMENT+PLATFORM_ALIGNMENT)%PLATFORM_ALIGNMENT)
--- 50,55 ----
***************
*** 97,102 ****
--- 94,100 ----
extern void start_memory_manager(void);
extern void shutdown_memory_manager(void);
+ extern void memory_manager_status(unsigned char verbose);
#endif
Index: php31/main/tls.h
diff -c php31/main/tls.h:2.4 php31/main/tls.h:2.5
*** php31/main/tls.h:2.4 Thu Aug 20 17:50:32 1998
--- php31/main/tls.h Thu Aug 20 20:15:28 1998
***************
*** 47,52 ****
--- 47,56 ----
#include "sapi/sapi.h"
#include "php3_ini.h"
+ /* from alloc.c */
+ #define MAX_CACHED_MEMORY 64
+ #define MAX_CACHED_ENTRIES 16
+
typedef struct php3_global_struct
{
/*all globals must be here*/
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net