Yii Framework Forum: CActiveFinder memory leaks - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CActiveFinder memory leaks Rate Topic: -----

#1 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 27 May 2010 - 01:19 AM

// YII_DEBUG => false
// No one of ARModel didn't has behaviors
// PHP version is 5.2.13 (apache/2.2.14 win xp sp3)


$db = Yii::app()->getDb();
$i=20;
echo "<pre>";

while($i--){
	echo memory_get_usage(true)."\n";

	// flush connection to prevent PDO leaks
	$db->setActive(false);
	$db->setActive(true);

	SomeArRecord::model()->findAll(array(
		'with'=>array(
			'related' => array(
				'with' => array(
					'related',
					'related2',
				),
			),
			'related2',
		),
		'limit'=>1000,
	));
}


output:
2359296
9699328
12845056
16252928
19398656
22544384
25952256
29097984
32243712
35389440
38535168
42467328
45613056
48758784
51904512
55050240
58195968
61341696


Any suggestions?
-Posted Image-
Thanks, you make me stronger!
0

#2 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 27 May 2010 - 01:23 AM

+ one more interesting thing: if add few lines to CActiveFinder/CActiveRecord/CJoinElement

public function __destruct(){
  echo "destructed\n";
}


__destruct's output will appears after all "memory lines" :huh: (I mean that AR need to be refactored, because all of result instances (with related object) live until script shutdown) - need use temporary cache instead of object's properties
-Posted Image-
Thanks, you make me stronger!
0

#3 User is offline   parpaing 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 20-April 10

Posted 02 June 2010 - 08:09 AM

Hello !

I recently ran into the exact same problem, and opened a topic in the bug forum :
http://www.yiiframew...dpost__p__47449

In this post, I proposed a little hack that solved the problem for me.
You may want to give it a try ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users