@@ -347,11 +347,13 @@ function testWatcherRegistrationAndCancellationInfo($type, $args)
347347 /** @dataProvider provideRegistrationArgs */
348348 function testNoMemoryLeak ($ type , $ args )
349349 {
350+ $ runs = 2000 ;
351+
350352 if ($ type === "onSignal " ) {
351353 $ this ->testSignalCapability ();
352354 }
353355
354- $ this ->start (function (Driver $ loop ) use ($ type , $ args ) {
356+ $ this ->start (function (Driver $ loop ) use ($ type , $ args, $ runs ) {
355357 $ initialMem = memory_get_usage ();
356358 $ cb = function ($ runs ) use ($ loop , $ type , $ args ) {
357359 $ func = [$ loop , $ type ];
@@ -444,17 +446,17 @@ function testNoMemoryLeak($type, $args)
444446 }
445447 };
446448 $ closureMem = memory_get_usage () - $ initialMem ;
447- $ cb (10000 ); /* just to set up eventual structures inside loop without counting towards memory comparison */
449+ $ cb ($ runs ); /* just to set up eventual structures inside loop without counting towards memory comparison */
448450 gc_collect_cycles ();
449451 $ initialMem = memory_get_usage () - $ closureMem ;
450- $ cb (10000 );
452+ $ cb ($ runs );
451453 unset($ cb );
452454
453455 gc_collect_cycles ();
454456 $ endMem = memory_get_usage ();
455457
456458 /* this is allowing some memory usage due to runtime caches etc., but nothing actually leaking */
457- $ this ->assertLessThan (40000 , $ endMem - $ initialMem ); // 4 * 10000 , as 4 is minimal sizeof(void *)
459+ $ this ->assertLessThan ($ runs * 4 , $ endMem - $ initialMem ); // * 4 , as 4 is minimal sizeof(void *)
458460 });
459461 }
460462
@@ -496,7 +498,7 @@ function testExecutionOrderGuarantees()
496498 $ del1 = $ loop ->delay ($ msDelay = 0 , $ dep (1 , $ del ));
497499 $ del2 = $ loop ->delay ($ msDelay = 0 , $ dep (3 , $ del ));
498500 $ del3 = $ loop ->delay ($ msDelay = 0 , $ f ());
499- $ del4 = $ loop ->delay ($ msDelay = 0 , $ f (1 , 3 ));
501+ $ del4 = $ loop ->delay ($ msDelay = 0 , $ dep ( 1 , $ defdel = $ f (1 , 3 ) ));
500502 $ loop ->cancel ($ del3 );
501503 $ loop ->disable ($ del1 );
502504 $ loop ->disable ($ del2 );
@@ -506,19 +508,21 @@ function testExecutionOrderGuarantees()
506508 $ loop ->disable ($ writ1 );
507509 $ loop ->disable ($ writ2 );
508510 $ loop ->enable ($ writ1 );
509- $ writ4 = $ loop ->onWritable (STDIN , $ f (1 , 3 ));
511+ $ writ4 = $ loop ->onWritable (STDIN , $ dep ( 1 , $ defwrit = $ f (1 , 3 ) ));
510512 $ loop ->onWritable (STDIN , $ dep (2 , $ writ ));
511513 $ loop ->enable ($ writ2 );
512514 $ loop ->disable ($ writ4 );
513- $ loop ->defer (function () use ($ loop , $ writ4 ) {
515+ $ loop ->defer (function () use ($ loop , $ writ4 , $ dep , $ defwrit ) {
516+ $ loop ->onWritable (STDIN , $ dep (0 , $ defwrit ));
514517 $ loop ->enable ($ writ4 );
515518 });
516519
517520 $ loop ->enable ($ del1 );
518521 $ loop ->delay ($ msDelay = 0 , $ dep (2 , $ del ));
519522 $ loop ->enable ($ del2 );
520523 $ loop ->disable ($ del4 );
521- $ loop ->defer (function () use ($ loop , $ del4 ) {
524+ $ loop ->defer (function () use ($ loop , $ del4 , $ dep , $ defdel ) {
525+ $ loop ->onWritable (STDIN , $ dep (0 , $ defdel ));
522526 $ loop ->enable ($ del4 );
523527 });
524528
0 commit comments