[pLog-svn] Some programming questions?

Oscar Renalias oscar at renalias.net
Wed Mar 5 17:30:41 EST 2008


Are we really sure that this would save any memory?

As far as I know, PHP's garbage collector will free the memory used by  
an object as soon as the object is out of the current execution scope.  
This means that if I create an object of type User via the "new"  
operator in my own function, its memory will be freed as soon as I  
leave my function. However, if I use a static reference to that  
object, its memory will not be freed until the request is over.

Is this really what we want to do in all cases?

On Mar 5, 2008, at 6:21 AM, Mark Wu wrote:

> Then, that sounds a good idea.
>
> So, your idea is not change all DAO method to static method. Your  
> idea is
> apply singleton pattern to all DAO objects.
>
> I think, It might reduce the memory usage.
>
> But, does there any drawbacks if we change to this?
>
> If not, I think it worth to give it a try.
>
> Mark
>
>> -----Original Message-----
>> From: plog-svn-bounces at devel.lifetype.net
>> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of howard chen
>> Sent: Wednesday, March 05, 2008 12:06 PM
>> To: LifeType Developer List
>> Subject: Re: [pLog-svn] Some programming questions?
>>
>> On Wed, Mar 5, 2008 at 12:00 PM, Mark Wu <markplace at gmail.com> wrote:
>>> Hi Howard:
>>>
>>> All DAO are extended from Model. And the model object include db
>>> connection  and basic CRUD method.
>>>
>>> If we change to static method, I am not sure we can do this easily.
>>>
>>> Take $blogs->addBlog(xxx) for example, if we change it to static
>>> method,  Blogs::addBlog(xxx), we need to change the method to the
>>> following(psuedo
>>> code)
>>>
>>> function addBlog(xxxx) {
>>> $model  = Model::getModelInstance();
>>> $model->table = Model::assignTable("blogs");  ....
>>
>> I think maybe follow the same way as $config is already good
>> enough, e.g.
>>
>> $articles = Articles::getInstance();
>> $articles->addArticle(...)
>>
>>
>> Howard
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://limedaley.com/mailman/listinfo/plog-svn
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn



More information about the pLog-svn mailing list