Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I've been pouring over the code in the distribution over the last day, and am putting together the code paths quite nicely, and I've learned a LOT about the shared memory subsystem in general. Also, I've never delved into tie'd variables before, so I went down that rabbit hole so I understood what's going on there.

I've copied the code into a new repository, and will get this sorted out for sure (as to why cleanup isn't working properly especially). Now that I know how the overall thing hangs together, I now know what part of my problem was...

In the case that was causing me the most grief, was having two separate processes running (ie. completely unrelated, two separate scripts/process stacks). When the first one went out of scope, it would remove all segments (and semaphores), thereby destroying the shared data in the process. When the other, still running proc next attempted to access the shared data, it would die because the underlying memory was gone.

That's why I couldn't use destroy, but because the cleanup routines don't reliably work, I was left with leaks.

So, I'm currently trying to figure out a) why the cleanup routines don't work in all cases and how to fix it, and b) the most logical way to ensure at least one segment stays alive until *all* processes (unrelated or not) go out of scope.

Because I'm still figuring it all out, I'm unsure how to do that yet, but one attempt will be trying to add a reference to the tied variable within the shared memory itself, and then pulling it in from there into each separate object that accesses it. Whether that's a valid approach, I'm unsure at this time.

There are quite a few things within the code already I see I'm going to want to modify/remove/add, but everything completely hinges on me getting the clean routines working precisely. I'm even weighing the possibility of ditching the tied var entirely, and going more along the lines of IPC::ShareLite, and adding in my own serialization routine. That's thinking too far ahead yet though; I still need more knowledge on the "keeping the data shared, while keeping the memory segments/semaphores in check" stuff.

I'll definitely be writing a blog post about this entire learning process once I've got an exceptionally good grasp of things. This isn't something I thought I'd get so distracted by, but I've found that it's a very interesting topic, and I can already see future uses for some of my projects (even stuff that the Shareable modules don't yet currently do).


In reply to Re^4: IPC::Shareable sometimes leaks memory segments by stevieb
in thread IPC::Shareable sometimes leaks memory segments by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found