LoginSignup
1
2

More than 5 years have passed since last update.

Ethnaでメモリーリーク

Last updated at Posted at 2013-03-22

PHP5.1/Ethna2.5で発生。
PHP5.4だと程度は減るがやはりリークする。

$this->af->setApp('data', $veryBigData);

みたいに巨大な配列をsetAppしたときに問題が起こる。

Ethnaでは下記のようなメソッドコールが行われ、_getArrayで上記の$veryBigDataが再帰的に処理されるのだが、ここでPHP(httpd)がもりもりメモリを喰ってしまい、リクエスト終了後もメモリをつかんだまま離さない。

- Controller::_trigger_WWW
 - ViewClass::preforward
 - ViewClass::forward
   - ViewClass::_getRenderer
    - ActionForm::getAppArray
     - ActionForm::_getArray(→再帰)

対処方法

Controller::_trigger_WWW()の中で、forward()直後に下記のようにunsetしてやれば
いくぶんかマシになる。(ただし根本解決ではない)

$this->view->forward();

unset($this->action_form->app_vars);
unset($this->action_form->app_ne_vars);
unset($this->action_form->form_vars);

原因はよくわからないが、EthnaはControllerやらActionやらBackendやらのインスタンスが相互に参照しあってるので、循環参照になっているのが原因かも?

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2