Перейти к основному содержанию.

PHP memory allocation problem


If PHP fails to allocate memory it returns one of the following errors: OR No 1 occurs when PHP memory limit is reached and it is the limit which is controlled by memory_limit setting at php.ini.
No 2 comes from the operating system, php limit is not reached and changing php.ini will not help whatever people are advising about it.

Just have a look at the source of zend_alloc.c if you have doubts ...

  1. if (segment_size < true_size ||
  2. heap->real_size + segment_size > heap->limit) {
  3. /* Memory limit overflow */
  4. #if ZEND_MM_CACHE
  5. zend_mm_free_cache(heap);
  6. #endif
  7. HANDLE_UNBLOCK_INTERRUPTIONS();
  8. #if ZEND_DEBUG
  9. zend_mm_safe_error(heap,
  10. "Allowed memory size of %ld bytes exhausted at %s:%d (tried to allocate %lu bytes)",
  11. heap->limit, __zend_filename, __zend_lineno, size);
  12. #else
  13. zend_mm_safe_error(heap,
  14. "Allowed memory size of %ld bytes exhausted (tried to allocate %lu bytes)",
  15. heap->limit, size);
  16. #endif
  17. }
  18.  
  19. segment = (zend_mm_segment *) ZEND_MM_STORAGE_ALLOC(segment_size);
  20.  
  21. if (!segment) {
  22. /* Storage manager cannot allocate memory */
  23. #if ZEND_MM_CACHE
  24. zend_mm_free_cache(heap);
  25. #endif
  26. HANDLE_UNBLOCK_INTERRUPTIONS();
  27. out_of_memory:
  28. #if ZEND_DEBUG
  29. zend_mm_safe_error(heap,
  30. "Out of memory (allocated %ld) at %s:%d (tried to allocate %lu bytes)",
  31. heap->real_size, __zend_filename, __zend_lineno, size);
  32. #else
  33. zend_mm_safe_error(heap,
  34. "Out of memory (allocated %ld) (tried to allocate %lu bytes)",
  35. heap->real_size, size);
  36. #endif
  37. return NULL;
  38. }
^ TOP

17/04/2008

Комментарии

Комментарий от maxirmx:

Sometimes out of memory is related to this bug.

Комментарий от maxirmx:

Also here

 
( ):