mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Optimize openssl memory leak test
Just do one call and check whether memory usage changes. Looping this 100000 times is extremely slow with debug builds of openssl.
This commit is contained in:
@@ -2,10 +2,6 @@
|
||||
Bug #79145 (openssl memory leak)
|
||||
--EXTENSIONS--
|
||||
openssl
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv('SKIP_SLOW_TESTS')) die('skip slow test');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$b = '-----BEGIN PUBLIC KEY-----
|
||||
@@ -15,13 +11,14 @@ j85Q5OliVxOdB1LoTOsOmfFf/fdvpU3DsOWsDKlVrL41MHxXorwrwOiys/r/gv2d
|
||||
C9C4JmhTOjBVAK8SewIDAQAC
|
||||
-----END PUBLIC KEY-----';
|
||||
|
||||
$a = openssl_get_publickey($b);
|
||||
@openssl_free_key($a);
|
||||
|
||||
$start = memory_get_usage(true);
|
||||
for ($i = 0; $i < 100000; $i++) {
|
||||
$a = openssl_get_publickey($b);
|
||||
@openssl_free_key($a);
|
||||
}
|
||||
$a = openssl_get_publickey($b);
|
||||
@openssl_free_key($a);
|
||||
$end = memory_get_usage(true);
|
||||
var_dump($end <= 1.1 * $start);
|
||||
var_dump($end == $start);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
|
||||
Reference in New Issue
Block a user