Welcome Guest, Not a member yet? Register   Sign In
Object destruction
#1

[eluser]steveeakin[/eluser]
Does CI handle the destruction of objects or does it let PHP's garbage collector take care of it?

If CI handles it, when and where does it go?
#2

[eluser]TheFuzzy0ne[/eluser]
As far as I am aware, the destruction of objects is left to PHP's garbage collection process.
#3

[eluser]Dam1an[/eluser]
I agree with Fuzz... It makes sense to leave it up to PHP, as it just gets rid of everything when the script terminates, where as CI would need to keep track of what gets used where, and it doesn't know if something would be used later on etc

I think the only 'clean up' CI does is close the database connection if it exists at the end
#4

[eluser]steveeakin[/eluser]
Than you all for the replies. I was hoping there would be a model destruction when the view is called since at that point, it should be done. It is pretty insignificant, but would have given one more detail in the benchmarking department (from construction to destruction of a model.)
#5

[eluser]Dam1an[/eluser]
Well, you can always create a __destruct method (maybe to MY_Controller and MY_Model) so if you start a timer in the constructor and stop it in the destructor, you know how much time was spent in that model
#6

[eluser]steveeakin[/eluser]
[quote author="Dam1an" date="1245444627"]Well, you can always create a __destruct method (maybe to MY_Controller and MY_Model) so if you start a timer in the constructor and stop it in the destructor, you know how much time was spent in that model[/quote]

That is the way I have it set up now, but it could be a pain for every developer to have to do that in every controller that uses a model. Even if its one line of code, its hard to manage with multiple people.
#7

[eluser]Dam1an[/eluser]
Thats why I said put it in the parent Controller/Model, then you only do it once, and it takes care of itself assuming you extend the new parent object instead of the CI parent




Theme © iAndrew 2016 - Forum software by © MyBB