|
Posted by Jerry Stuckle on 07/04/07 01:42
vivek@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.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|