Wednesday, 28 August 2013

How does PHP copy() handle memory

How does PHP copy() handle memory

I need to use PHP's copy() function to copy files from one location to
another. I am intentionally not using rename().
The files are 500MB to 1GB. It seems that it takes about 10-20 seconds to
move them after I start the PHP script (one file is handled per
execution).
My server was rejecting the upload of these files because of
max_execution_time, post_max_size, upload_max_filesize and memory_limit
values, all of which are set ridiculously high, but the server would just
time out when I was trying to upload.
Now I'm concerned the server will fail if this copy() operation is running
while the site is dealing with a lot of traffic.
So my question is, does PHP's copy() operate in a way that would overload
the server's memory and/or execution time limits?
I know that the PHP script takes a lot of time to complete, but my hope is
that the time is essentially just a period of low-memory "waiting time" as
PHP sits back and lets the server OS move the file... I wouldn't think
that PHP would need to load the file into a buffer or anything like that
in order to copy it, but memory discussion on this level is a topic a bit
out of my understanding.
Can anyone explain how PHP copy() uses memory, and if there are any risks
associated with memory overloads?

No comments:

Post a Comment