hi Rasmus, I don't know all the APC internals, but it seems it just doesn't free memory carefully. It sets zend_class_entry->refcount to something above 1000 and as result all the nested structures are not freed as expected by destroy_zend_class().
I'm not sure which side effects this may have, but one of them is avoiding of the trait related problem :) Of course, It produces many memory leaks but most of them (probably all) must be handled by zend_alloc $ PHP_FCGI_MAX_REQUESTS=2 USE_ZEND_ALLOC=0 valgrind sapi/cgi/php-cgi -b /tmp/fcgi-php5 ... ==30930== definitely lost: 676 bytes in 10 blocks ==30930== indirectly lost: 1,213 bytes in 24 blocks ... ~2K memory leaks on 2 HTTP requests (the same trait.php test) It also must change the destruction order of static members and methods static variables, but I'm too lazy to prove it. Anyway, the traits problem really exists and I almost found a solution for 5.4 without BC break. I'll post a patch tomorrow or on next week. Thanks. Dmitry. On Thu, Dec 20, 2012 at 9:04 PM, Rasmus Lerdorf <ras...@lerdorf.com> wrote: > On 12/20/2012 06:36 AM, Dmitry Stogov wrote: > > Hi Pierre, > > > > The following test may crash on the second request with opcode cache. > > > > <?php > > > > trait THello { > > > > public function hello() { echo 'Hello'; } > > } > > > > class TraitsTest { use THello; } > > > > $test = new TraitsTest(); > > $test->hello(); > > > > ?> > > > > Valgrind shows the problem even if PHP doesn't crash. > > I'm not seeing anything from Valgrind's memcheck on this under php -S > with current PHP 5.4 and APC. Testing on 64-bit Linux. > > -Rasmus > >