How are you using fread?

Something like

$contents = fread($handle, filesize($filename));

Will read the whole thing into memory, which is not something you
really want to do as previously noted

Can you tell us a little more about the nature of the file?

If its textual rows, with the \n character, then you'll be wanting to
use fgets() to read one line at a time.

If its xml, then look at the xml parsing functions.

HTH,

Matt


On Fri, Jan 2, 2009 at 10:50 AM, Michael <[email protected]> wrote:
>
> On Fri, 02 Jan 2009 07:28:45 Tony Rigden wrote:
> > Are you trying to load the entire file into memory? fread will read
> > only a maximum of 8192 bytes at a time. See http://nz2.php.net/fread.
> > It is not desirable to the memory limit that high nor should it be
> > needed. Most people have it set to a max of about 32 Mb if they are
> > using graphics or less if not.
> >
> > Tony
>
> Do you have any idea what could be causing this then please?
>
> Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to
> allocate 2023545829 bytes) in /www/scan.php on line 145
>
> Line 145 is a call to fread()
>
> Kind regards,
>
> Michael
>
> >

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to