I am getting a crash, probably related to memory usage, while parsing a large (100MB) comma separated text file using Text::CSV_XS. Crash occurs on both Kubuntu (Plasma segfault) and Windows (process is killed). I am reading the CSV file in order to perform some basic funtions (min/max, distinct) on each column. The crash occurs using either CSV_XS or CSV_PP. Here is the test case, you will need to scare up a test.file which is CSV and very large:
#!/usr/bin/perl use strict; use warnings; use Text::CSV_PP; use Text::CSV_XS; use Text::CSV; my @array; my $csv = Text::CSV->new ({ binary => 1, sep_char=>','}) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $FH2, "<:encoding(utf8)", "test.file" or die "$file: $!"; while (my $row = $csv->getline ($FH2) ) { {push @array, $row;} } $csv->eof or $csv->error_diag (); close $FH2;
When running the code, I see memory usage climb to near 100% (2GB installed) and then the crash occurs.

So my questions are: why is the crash occurring and how can I avoid it? I've read whatever I can find on the subject, and I can't find anyone else having the same problem. People report success reading files over 100GB, but I crash out around 100MB. Thanks in advance for any help, and apologies in advance for missing any obvious resources for help. I did search...


In reply to Text CSV_XS memory crash by glepore70

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.