laruence / yaconf

A PHP Persistent Configurations Container

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yaconf 内存溢出bug

WLWL opened this issue · comments

php 版本 7.0.7
yaconf 版本 1.0.2

运行下面的代码 PHP 进程的内存会一直增加。

while(true){
$acc = yaconf::get('topic.time_line');
array_walk_recursive($acc, function ($item) {
});
var_dump(Memory_get_usage());
}

这样内存会一直增长。

代码呢?

while(true){
$acc = yaconf::get('topic.time_line');
array_walk_recursive($acc, function ($item) {
});
var_dump(Memory_get_usage());
}

这样内存会一直增长。

$ /home/huixinchen/local/php7/bin/php /tmp/1.php
array(3) {
  [0]=>
  string(5) "xxxxx"
  [1]=>
  string(5) "xxxxx"
  [2]=>
  string(5) "xxxxx"
}
int(368624)
array(3) {
  [0]=>
  string(5) "xxxxx"
  [1]=>
  string(5) "xxxxx"
  [2]=>
  string(5) "xxxxx"
}
int(368624)
array(3) {
  [0]=>
  string(5) "xxxxx"
  [1]=>
  string(5) "xxxxx"
  [2]=>
  string(5) "xxxxx"
}
int(368624)

我这里没有增长啊, 你的topic.ini是啥样的

while(true){ $acc = yaconf::get('topic.time_line'); //$item 前面加个引用 array_walk_recursive($acc, function (&$item) { }); var_dump(Memory_get_usage()); }

只要对yaconf 里面的值做了引用就会出现内存一直增长

while(true){
$acc = yaconf::get('topic.time_line');
foreach ($acc as &$item){

}
var_dump(Memory_get_usage());
}

应该已经修复了, 你拉取github上的代码重新编译下试试, thanks