1--TEST--
2Check for EvWatcher object destructors(leaks)
3--INI--
4memory_limit=2M
5--FILE--
6<?php
7$limit = 100000;
8
9$callback = function() {
10	static $i = 0;
11	echo "cb ", ++$i, PHP_EOL;
12};
13
14// Create and destroy EvTimer objects in loop.
15// EvTimer's constructor starts the watcher automatically.
16// Thus, eventually only one timer should fire.
17$n = 0;
18while (++$n < $limit) {
19    $timer = new EvTimer(-1, 0, $callback);
20    //Ev::run(Ev::RUN_NOWAIT | Ev::RUN_ONCE);
21}
22Ev::run();
23echo $n, PHP_EOL;
24
25// Create stopped timers and destroy them in loop.
26// No timer should fire even after Ev::run() call.
27// We're checking whether stopped watchers exhaust the memory.
28$n = 0;
29while (++$n < $limit) {
30    $timer = EvTimer::createStopped(-1, 0, $callback);
31    //Ev::run(Ev::RUN_NOWAIT | Ev::RUN_ONCE);
32}
33Ev::run();
34echo $n;
35?>
36--EXPECT--
37cb 1
38100000
39100000
40