$OpenBSD: patch-Zend_zend_alloc_c,v 1.1 2001/08/11 00:16:56 avsm Exp $
--- Zend/zend_alloc.c.orig	Tue Jun 19 18:04:53 2001
+++ Zend/zend_alloc.c	Sat Aug 11 00:07:15 2001
@@ -446,6 +446,9 @@ ZEND_API void shutdown_memory_manager(in
 		for (i=1; i<MAX_CACHED_MEMORY; i++) {
 			for (j=0; j<AG(cache_count)[i]; j++) {
 				ptr = (zend_mem_header *) AG(cache)[i][j];
+#if MEMORY_LIMIT
+				AG(allocated_memory) -= REAL_SIZE(ptr->size);
+#endif
 				REMOVE_POINTER_FROM_LIST(ptr);
 				free(ptr);
 			}
