summaryrefslogtreecommitdiff
path: root/Zend/zend_alloc.c
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-08-19 16:35:02 +0000
committerZeev Suraski <zeev@php.net>2000-08-19 16:35:02 +0000
commit07b5d74022c5471c096b73a708a088fcd975efbd (patch)
tree123e31814202b7e8cd60e34568f11e2ae89b13f0 /Zend/zend_alloc.c
parentc698e14635156e8d55187728943f5d48573fe8f4 (diff)
downloadphp-git-07b5d74022c5471c096b73a708a088fcd975efbd.tar.gz
Fix memory_limit
Diffstat (limited to 'Zend/zend_alloc.c')
-rw-r--r--Zend/zend_alloc.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index b5025414a7..f33aee46d8 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -57,11 +57,18 @@ ZEND_API zend_alloc_globals alloc_globals;
#define _CHECK_MEMORY_LIMIT(s, rs, file, lineno) { AG(allocated_memory) += rs;\
if (AG(memory_limit)<AG(allocated_memory)) {\
- if (!file) { \
- zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)", AG(memory_limit),s); \
- } else { \
- zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)", AG(memory_limit), file, lineno, s); \
- } \
+ if ((AG(memory_limit)+1048576)<AG(allocated_memory)) { \
+ /* failed to handle this gracefully, exit() */ \
+ exit(1); \
+ } \
+ if (!AG(memory_exhausted)) { \
+ if (!file) { \
+ zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted (tried to allocate %d bytes)", AG(memory_limit),s); \
+ } else { \
+ zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)", AG(memory_limit), file, lineno, s); \
+ } \
+ AG(memory_exhausted)=1; \
+ } \
} \
}
# endif
@@ -435,6 +442,7 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
}
}
#endif
+ AG(allocated_memory) -= t->size;
p = t->pNext;
REMOVE_POINTER_FROM_LIST(t);
free(t);
@@ -451,6 +459,7 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
}
}
}
+ AG(memory_exhausted)=0;
#if (ZEND_DEBUG)
do {