SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Php 5.2 - Memory Exhausted Issue

    Hello,

    What is different in terms of memory handling in php 4 and php 5.

    I have a simple script that parses a large CSV file and it works fine in all version of php 4 whereas in php 5 it exhausts all the memory.

    In PHP5, no matter how much memory size I increase, I get out of memory. As the script goes on processing each line the memory usage on the server keeps going up and up until it hit the limit and script is killed.

    In PHP4, it works like a charm using similar amount of memory until it process full 100,000 lines of CSV.

    Following is the basics of the code. In $arrCols I keep assigning the array for each line of the CSV. Should I do something extra for it to work in php5 like free $arrCols before assigning it again or something.

    PHP Code:
    $fp fopen($filepath"r");

    while ( !
    feof($fp) )
    {
        
    $arrCols fgetcsv($fp65000',''"');

        
    // Do some stuff with the $arrCols here //

    Please do help.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,260
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    no memory

    Perhaps the feof and fgetscsv are redundant? Although my csv file isn't that large, this works OK for me
    PHP Code:
    $ff fopen("wildflowerdata.csv","r");
    while ((
    $data fgetcsv($ff110"|")) !== FALSE) { 

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Will this effect memory (separate checks or one check)?

    Quote Originally Posted by Mittineague View Post
    Perhaps the feof and fgetscsv are redundant? Although my csv file isn't that large, this works OK for me
    PHP Code:
    $ff fopen("wildflowerdata.csv","r");
    while ((
    $data fgetcsv($ff110"|")) !== FALSE) { 
    Price Comparison Script - Start your own price comparison website
    Adbrite clone - Start your own ad network


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •