btherl Posted January 14, 2009 Share Posted January 14, 2009 I'm looking for a summary of php's issues with file sizes, but have been unable to find anything useful in google. From what I can tell from experimenting, the 32 bit php (version 4.3.10) cannot handle any file larger than 2GB, but the 64 bit php is ok. Is there anything I should know? Is a later version of 32 bit php able to handle large files? Thanks! Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted January 14, 2009 Share Posted January 14, 2009 It's very likely, as I'm sure you've figured, happening because PHP's hitting the limit of a signed 32 bit integer. What do you mean by "it can't handle files larger than 2 GB". Do you mean for any specific functions, or do you mean for something crazy such as a PHP script large enough to be over 2 GB in size? Quote Link to comment Share on other sites More sharing options...
btherl Posted January 14, 2009 Author Share Posted January 14, 2009 The operation in question is fopen() followed by fwrite(). When I tested it on the 32 bit php 4.3.10, it stopped writing at 2^31 - 1 bytes and crashed. So it's not about 2 gb php script I hope no-one has written one of those.. Quote Link to comment Share on other sites More sharing options...
aschk Posted January 14, 2009 Share Posted January 14, 2009 I didn't realise that php came in 32bit and 64bit versions... i thought your operating system + processor defined those ;-) Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted January 14, 2009 Share Posted January 14, 2009 When I tested it on the 32 bit php 4.3.10, it stopped writing at 2^31 - 1 bytes and crashed. So it's not about 2 gb php script I hope no-one has written one of those..More likely to be an operating system/filesystem limitation than a PHP limitation. e.g. Under ext3, If you are using a 1k filesystem, then a file can consist of ten direct blocks, plus 256 data blocks addressed via the indirect block, plus 256*256 data blocks addressed from the indirect block, plus 256*256*256 data blocks from the triple-indirect block: (10 + 256 + 256*256 + 256*256*256) * 1024 = 17247252480 However, take a look at this thread which discusses a 2GB file limit on 32-bit processors Quote Link to comment Share on other sites More sharing options...
btherl Posted January 15, 2009 Author Share Posted January 15, 2009 Thanks for that link. The problem is with php unfortunately, not the filesystem. We use the same filesystems here with 64 bit php and it deals with files over 2GB without trouble. It's just this particular job had to run on an older 32 bit machine (using the same fs via nfs). In the end we resolved it by making the necessary changes to have the job run on a 64 bit machine. aschk, we have both 32 bit and 64 bit OS here, and use 32 bit php on the 32 bit ones and 64 bit php on the 64 bit ones I'm not sure if you can make a 32 bit php on the 64 bit OS. But you definitely can't make the 64 bit on on a 32 bit OS. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.