Is there a way to make SOAP clean memory? I have a SOAP server (implemented with SOAP::Transport::HTTP, which uses SOAP::Lite, HTTP::Daemon, etc.) that returns the contents of many files.

One of the methods I've written returns a reference to an array so that it is encoded as an array when being returned (the client hitting my server is Java based). The array of file contents takes about 8 mB in memory. I notice, however, that 16 mB (over the ~6 mB that is consumed before the array is loaded) is being used by the server. My assumption is that the 8 mB extra is from the serialization process and that it copies the array in memory.

That is a side point, though. The memory is not freed after SOAP returns the data to the client. The 16 mB is held in memory for quite a long time. I called the server several times asking for different files until finally it returned the memory. That prompted me to try calling it N times to free the memory, it's not based on the number of calls. It does appear to be based on time or time between calls. It seems to top out at 25 mB. Then it doesn't use any beyond that.

I've read quite a bit of documentation and not found anything explaining how the memory works. Does anyone here know how? And does anyone know how to control when the memory is freed (I would like to free it as soon after the return as possible)?

Please let me know if you would like to see the code for the server.

Thank you!
Casey

In reply to Does SOAP clean memory? by cmilfo

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.