I'm currently trying to port DateTime::TimeZone to XS so that it consumes less memory. But I'm currently being baffled by the seeming *increase* in the memory being used by loading the XS version of the module.

DateTime::TimeZone is comprised of a a base class, DateTime::TimeZone, and a few hundred subclasses which represent each time zone. For example, Asia/Tokyo timezone is represented as DateTime::TimeZone::Asia::Tokyo. Each of these timezones contains a list of data, which I've now converted to C structs.

Now, loading one time zone and comparing its size with what Devel::Size reports, the savings are clear. Here's an example:

Europe/Belfast: 51735 (Pure Perl) Europe/Belfast: 2525 (XS)

However, this isn't translating into actual memory savings. This is the output from my top (Mac OS X)

PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSI +ZE VSIZE (XS) 26873 perl 0.0% 0:03.43 1 12 1177 14.6M 12.0M 2 +1.9M 51.0M (PP) 26872 perl 0.0% 0:02.83 1 12 46 13.4M 1.42M 1 +4.6M 33.3M

What gives? The XS version seems to consume more than 18 MB more than the pure perl version?! I think I've applied all the XS hackery I know to reduce memory consumption, is there any tips to reduce this memory size? or am I looking at the wrong numbers?


In reply to memory penalty for loading XS modules? by lestrrat

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.