With iThreads, under Win32, the memory for at least some of perl's internal datastructures is allocated from Thread Local Storage, and is so (at least notionally) only accessible from the thread in which it is created.

There is also (under 5.8.x at least) a C++ class wrapped around an OS provided LocalMemAlloc() API.

If either of these are the case with the version of Perl you are using, which is quite possible as iThreads evolved initially as a substitute for fork on Win32 in 5.6.1; and if you are allocating memory from the global heap in your C threads; and you are trying to share the two types of memory across both types of threads--this may explain (some) of your problems.

There are a lot of 'ifs' in that, and it may be a complete red herring, but like you I have attempted to track through the memory allocation macros used by Perl (5.8.5 in my case) and they are incredibly deeply nested and very hard to follow.

I think that your best source of advice would be the p5p list, and if your working on Win32 maybe the perl-win32 porters list also.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re: General memory management for embedded/extended perl with C threads by BrowserUk
in thread General memory management for embedded/extended perl with C threads by Anonymous Monk

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.