File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // script to check for memory leaks
4
+
5
+ require __DIR__ .'/../../../vendor/autoload.php ' ;
6
+
7
+ $ loop = new React \EventLoop \StreamSelectLoop ();
8
+
9
+ $ i = 0 ;
10
+
11
+ $ loop ->addPeriodicTimer (0.001 , function () use ($ loop , &$ i ) {
12
+ $ i ++;
13
+
14
+ $ client = new DNode \DNode ($ loop );
15
+ $ client ->connect (7070 , function ($ remote , $ conn ) {
16
+ $ remote ->zing (33 , function ($ n ) use ($ conn ) {
17
+ $ conn ->end ();
18
+ });
19
+ });
20
+ });
21
+
22
+ $ loop ->addPeriodicTimer (2 , function () use (&$ i ) {
23
+ $ kmem = memory_get_usage (true ) / 1024 ;
24
+ echo "Run: $ i \n" ;
25
+ echo "Memory: $ kmem KiB \n" ;
26
+ });
27
+
28
+ $ loop ->run ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ // script to check for memory leaks
4
+
5
+ require __DIR__ .'/../../../vendor/autoload.php ' ;
6
+
7
+ $ loop = new React \EventLoop \StreamSelectLoop ();
8
+
9
+ class Zinger
10
+ {
11
+ public $ i = 0 ;
12
+
13
+ public function zing ($ n , $ callback )
14
+ {
15
+ $ this ->i ++;
16
+ $ callback ($ n * 100 );
17
+ }
18
+ }
19
+
20
+ $ zinger = new Zinger ();
21
+
22
+ $ server = new DNode \DNode ($ loop , $ zinger );
23
+ $ server ->listen (7070 );
24
+
25
+ $ loop ->addPeriodicTimer (2 , function () use ($ zinger ) {
26
+ $ kmem = memory_get_usage (true ) / 1024 ;
27
+ echo "Run: {$ zinger ->i }\n" ;
28
+ echo "Memory: $ kmem KiB \n" ;
29
+ });
30
+
31
+ $ loop ->run ();
You can’t perform that action at this time.
0 commit comments