The XML file is 21.5MB in size. I know it gets stuck at the point of parsing the file

Does it still fail if you try it on a smaller file? (Like the sample you posted.)

If not, it suggests that the the process of parsing the file and building the complex, nested data-structure that results from it, is consuming more memory than is available.

Suggestions:

  1. Install a 64-bit Perl.

    32-bit perls are limited to using 2GB of memory. Most machines these days have much more than this available.

    A 64-bit Perl will allow you to use all the memory your machine has available.

  2. Use a different XML parser.

    XML::Smart is a particularly memory hungry module because of its design. Another XML parser might be able to parse the whole file whilst using less memory.

    Some XML modules are explicitly designed to handle files that are too big for memory, by only parsing/retaining a subset of the file in memory at any given time. eg. XML::Twig


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Perl XML::Smart Out of memory! error by BrowserUk
in thread Perl XML::Smart Out of memory! error by nasaa

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.