bug61371-unix.phpt 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #61371: stream_context_create() causes memory leaks on use streams_socket_create
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) == 'WIN' ) {
  6. die('skip non windows test');
  7. }
  8. --FILE--
  9. <?php
  10. function test($doFclose) {
  11. $previous = null;
  12. $current = null;
  13. for($test=1;$test<=3;$test++) {
  14. $current = memory_get_usage(true);
  15. if (!is_null($previous)) {
  16. var_dump($previous == $current);
  17. }
  18. $previous = $current;
  19. echo 'memory: '.round($current / 1024, 0)."kb\n";
  20. for($i=0;$i<=100;$i++) {
  21. $context = stream_context_create(array());
  22. $stream = stream_socket_client('udp://0.0.0.0:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context);
  23. if ($doFclose) fclose($stream);
  24. unset($context);
  25. unset($stream);
  26. unset($errno);
  27. unset($errstr);
  28. }
  29. }
  30. }
  31. test(true);
  32. test(false);
  33. ?>
  34. --EXPECTF--
  35. memory: %dkb
  36. bool(true)
  37. memory: %dkb
  38. bool(true)
  39. memory: %dkb
  40. memory: %dkb
  41. bool(true)
  42. memory: %dkb
  43. bool(true)
  44. memory: %dkb