BrowserUk,
I know what closures are and how they work. I'm asking how you are going to fake a closure?

Hmmm. Classic example of how things that are clear in your mind don't make any sense to anyone else because you assume they know what you are thinking. By faking the closure, I mean get the same effect - causing the reference count to increase by one so when it goes out of scope it doesn't reach 0.

To avoid that, you would need to keep a copy of the unsmashed reference around. To do that, you need to put it somewhere:

This is the exact thing I am proposing you don't have to do. It is in scope at the time you are stringifying it. If the only thing (which is my understanding) that is keeping it from being GC'd when it goes out of scope is the reference count - just increase it. You use the stringified address to look it up later, you GC it by lowering the ref count.

If the idea isn't clear (forget workable for now) then let me know and I will try a non-commentary approach.

Cheers - L~R

P.S. I didn't indicate that XS wouldn't be required though it would be really cool if it wasn't.


In reply to Re^6: Techniques On Saving Memory by Limbic~Region
in thread Techniques On Saving Memory by Limbic~Region

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.