Forum Moderators: coopster

Message Too Old, No Replies

Q: PHP memory footprint in include() & RW

         

Guardian

12:44 pm on Jan 25, 2004 (gmt 0)

10+ Year Member



Hi

I am looking at options for the project I am coding using OOP & flat-file database.

Question I have is regarding the memory & resource management of inlcude() and Read/Write to files.

For example, based on 100kb worth of data:
I gather it would be more memory efficient if data was in smaller chunks i.e. 2kb [x50]. This was on each include(), only 2 kb is included and PHP has to read, write to file or parse 2kb of data.

But on the other hand, PHP may need to open/read/write 5-10 files or more in each exec of script.

Question is:
- Would open/read/write of 10x2 kb be more efficient than open/read/write of 1x100 kb file?

- How would the equation change if data in question was 1000kb and numbers of files used in each exec were 100x2 kb?

I look forward to your comments.

TIA
:)

ergophobe

4:07 pm on Jan 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



On the memory questions, I don't know off hand about file size, but since you mentioned OOP I thought I would throw this in. Prior to PHP5, objects are passed by value, which can eat up a lot of memory. You will probably want to explicitly pass them by reference. If you upgrade to PHP5, I think you'll have to go back and change your function definitions. I know that was a concern of the designers, but I can't remember how they dealt with it.

Alternatively, I guess you could upgrade to PHP5 now and save yourself the trouble. It's on beta 3, so it should be pretty good.

Tom