1

I'm new to Zend engine and writing an extension. According to this page if I want to remove all elements from a hashtable but not actually destroy everything, then I can use the zend_hash_clean() function.

However, when I carefully studied this particular function, I realised that the array of buckets is not released as in zend_hash_destroy() even though the destructor is invoked for each bucket element and all the other values are reset (nNumUsed, nNumOfElements, nInteralPointer, etc.).

I highly suspect this is the source of my memory leaks.

Please let me know if I'm wrong. Any suggestion or pointer is much appreciated.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
J. Tam
  • 11
  • 1
  • 1
    That's quite the point of clean, to not release the Buckets and index maps and be able to reuse it… it's basically equivalent to destroy+init again. Use destroy if you want to free the memory. – bwoebi Jun 30 '16 at 14:48
  • But as far as I can tell, the indices have been reset (reinitialized as you said) and yet the buckets are not released. When a new value is inserted, new memory is allocated... thus memory leaks occur. Thanks! – J. Tam Jul 07 '16 at 17:26
  • Did you call `FREE_HASHTABLE()`? – Frederick Zhang Oct 06 '16 at 14:32

0 Answers0