[nycphp-talk] Memory Limit
Sterling Hughes
sterling at bumblebury.com
Fri Jan 3 14:13:48 EST 2003
> <paralist>This message contained 1 file(s) and is available at http://nyphp.org/list/paralist_archive.php?L_mid=2111</paralist>
>
> --- Sterling Hughes <sterling at bumblebury.com> wrote:
> > > Hi,
> > >
> > > There are two simple ways to have more free memory for your scripts :
> > >
> > > 1- You can increase memory limit from 8 Mb to any amount in php.ini file.
> > > 2- You can use 'unset()' function to unset unused variables right after
> > you use them.
> > >
> >
> > err, that should only be php 3 specific, php4's reference counting
> > mechanism releases all
> > variables the second they are no longer referenced in the script.
>
> But how would they become unreferenced without unset()ing them?
>
reference counting, that's how it works. :-) once you no longer reference
a variable in your script it is destroyed. Same applies for resources, like
filehandles. One they are no longer used, the files are closed.
http://www.zend.com/zend/art/ref-count.php
Now of course if you keep a lot of variables in one scope, then you should
explicitly free them, but chances are, if you're code is good, it should be modularized.
If you really do need to deref a variable, the best way is by:
$var = NULL;
-Sterling
>
> > > --- "Nunez, Eddy" <enunez at tiaa-cref.org> wrote:
> > > >
> > > > This is in reference to the standard memory limit for server PHP
>
> > scripts,
> > > > which is 8MB.
> > > >
> > > > My question is...
> > > > is there any function to query available free space in the memory pool?
>
> Maybe getrusage() would be handy, and I've attached a cheesy example I've
> used to quickly profile scripts, and the posix_* functions look good, too.
> Plus, you could always run the UNIX commands and parse the output for mem
> usage, what's free, etc on a system wide basis.
>
>
> =====
> Hans Zaunere
> President, New York PHP
> http://nyphp.org
> hans at nyphp.org
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>
More information about the talk
mailing list