Reply to Re: mysql_real_escape_string memory leak?

Your name:

Reply:


Posted by vivek on 07/05/07 17:51

On Jul 3, 6:42 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> v...@thoughtconvergence.com wrote:
> > Could someone please help me figure out why the memory usage
> > fluctuates when I use mysql_real_escape_string? I'm finding (what I
> > think are) memory leaks with a few mysql functions in php and I'm
> > trying to figure them all out. This one is pretty vexing. Thanks in
> > advance.
>
> > Here is example code:
> > class memTest {
> > function __construct() {
> > $con = mysql_connect("***************","*******","****");
> > if (!$con) {
> > die('Could not connect: ' . mysql_error());
> > }
> > mysql_select_db("*******", $con);
> > mysql_query("SET NAMES 'utf8'");
> > for ($i = 1; $i<=10; $i++) {
> > $temp = 'mysql';
> > echo "mem: ", memory_get_usage(), "\n";
> > echo mysql_real_escape_string($temp), "\n";
> > echo "mem: ", memory_get_usage(), "\n\n";
> > }
> > mysql_close($con);
> > }
> > }
> > $a = new memTest();
>
> > Here is what is output:
> > mem: 43216
> > mysql
> > mem: 43208
>
> > mem: 43208
> > mysql
> > mem: 43216
>
> > mem: 43216
> > mysql
> > mem: 43224
>
> > mem: 43224
> > mysql
> > mem: 43232
>
> > mem: 43232
> > mysql
> > mem: 43240
>
> > mem: 43240
> > mysql
> > mem: 43248
>
> > mem: 43248
> > mysql
> > mem: 43256
>
> > mem: 43256
> > mysql
> > mem: 43264
>
> > mem: 43264
> > mysql
> > mem: 43272
>
> > mem: 43272
> > mysql
> > mem: 43280
>
> And you're worried about *164 bytes* of memory?
>
> Do you actually have a problem? Or are you doing "premature optimization"?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

I am doing premature optimization. Eventually I'm going to be looping
~3.5 million times and inserting data into a table, so any memory leak
will be a problem.

Interestingly, when I increase the loop count to 1000, the memory
seems to stop increasing and stabilizes at iteration 256 (2^8). Prior
to that, the memory usage increases by 8 bytes each iteration. I'd
like to know why it increases in the first place, and how to prevent
it from increasing. Is there a way to force garbage collection in php?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация