Re: [PHP] PHP & Memory Allocation (checked via TOP)
- From: jon@xxxxxxxxxxxxxxxxxx (Jon Anderson)
- Date: Tue, 31 Oct 2006 07:52:50 -0500
Cabbar Duzayak wrote:
Hi,Just looked over this really quickly, so I might have missed something, but it seems to me that you're allocating almost 20 megs...
I have written a simple test program to see how php allocates memory.
Test code allocates ~10 Meg of RAM in an array within a loop till it
runs out of memory as:
$str = rand(65, 95) . rand(65, 95) . rand(65, 95) . rand(65, 95) .
rand(65, 95);
$aa[] = str_repeat($str, 2000000);
What I don't understand here is, for every 10 Meg memory it allocates,
mem usage goes up about 19 Megs when I look at this via top.
your $str is 10 bytes long (plus terminator and PHP overhead, whatever that turns out to be...), and you're repeating it two million times. 10 bytes times 2 million is 20 million bytes. 20 000 000 divided by (1024*1024) is 19.07 -> it seems to me that you're allocating 19.07 megs, and top is showing you that it's allocating 19 megs...? Seems about right.
jon
.
- References:
- PHP & Memory Allocation (checked via TOP)
- From: "Cabbar Duzayak"
- PHP & Memory Allocation (checked via TOP)
- Prev by Date: Re: [PHP] IIS Rewrite or Mod_Rewrite
- Next by Date: Re: [PHP] No Error Messages
- Previous by thread: Re: PHP & Memory Allocation (checked via TOP)
- Next by thread: need help with foreach
- Index(es):
Relevant Pages
|