Bug #74575 [Opn]: Memory leaks with gc_collect_cycles()

From: Date: Thu, 11 May 2017 16:32:56 +0000
Subject: Bug #74575 [Opn]: Memory leaks with gc_collect_cycles()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209076@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74575&edit=1 ID: 74575 User updated by: roocster at gmail dot com Reported by: roocster at gmail dot com Summary: Memory leaks with gc_collect_cycles() Status: Open Type: Bug Package: *General Issues -Operating System: Windows 10 x64 +Operating System: * PHP Version: 7.1.5RC1 Block user comment: N Private report: N New Comment: The bug is also reproduced on linux Previous Comments: ------------------------------------------------------------------------ [2017-05-11 16:14:20] roocster at gmail dot com Description: ------------ If make the situation described in the docs of "Collecting Cycles" (http://php.net/manual/en/features.gc.collecting-cycles.php) the gc_collect_cycles() doesn't collect garbage cycle reference. After we made an array which is referenced only by itself element (cycle reference) the gc_collect_cycles() call returns 0. That means there are not collected cycles and we have a memory leak. If we replace "$a = $a[0]" on "unset($a)" the garbage collector works correctly and the gc_collect_cycles() call returns 1. Test script: --------------- <?php echo "Memory usage before memory leak:\t", memory_get_usage()," bytes",PHP_EOL; $a = ['one']; $a[] = &$a; $a = $a[0]; echo "Memory usage after memory leak:\t\t", memory_get_usage()," bytes",PHP_EOL; echo "Number of collected cycles: ", gc_collect_cycles(),PHP_EOL; echo "Memory usage after gc_collect_cycles():\t", memory_get_usage()," bytes",PHP_EOL; Actual result: -------------- Memory usage before memory leak: 353368 bytes Memory usage after memory leak: 353392 bytes Number of collected cycles: 0 Memory usage after gc_collect_cycles(): 353392 bytes ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74575&edit=1

« previous php.bugs (#209076) next »