|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-03-24 18:11 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 00:00:02 2025 UTC |
PHP is using reference counter garbage collection so it is not able to deallocate objects with cyclic references. But it should not be a reason for corrupting memory. The following example cause either loosing value of object property either segmentation fault at PHP 4.3.1 and PHP-4.3.2RC1. The fault takes place after inserting 65533 objects (0xfffd - looks like somewhere short type is used:). In first case after inserting about 65k of objects the system reports "PHP Notice: Undefined property:" when accessing "opened" field in storeObject. <?php class Storage { var $opened; var $count; function Storage() { $this->objByOidMap = array(); $this->opened = true; $this->count = 0; } function storeObject(&$obj) { if ($this->opened) { if ($obj->__oid__ == 0) { $this->count += 1; $obj->__oid__ = $this->count; $obj->__storage__ = &$this; $this->objByOidMap[$obj->__oid__] = &$obj; } } } } class Object { var $__storage__; var $__oid__; } $storage = &new Storage(); for ($i = 0; $i < 100000; $i++) { print("i=$i\n"); $obj = &new Object(); $storage->storeObject($obj); } ?>