in reply to Re: Perl forking and shared memory strangeness under Windows
in thread Perl forking and shared memory strangeness under Windows

Thanks for the suggestion BrowserUk, I have reviewed the module code for Win32::MMF::Shareable, and after extensive debugging, I (think that I) have discoverred that the module might not be thread safe. I am doing some experiments at the moment to see if I could have independend sets of data both child and parents so they don't interfere with each other, as currently the child and parent share the same set of global data.

I tried your suggestion: I removed the use Win32::MMF::Shareable line at the start, which gets loaded at compile time, and then added require in each parent and child processes after the fork. The problem some how has gone away. The following is the test code I used:
#!C:/Perl/bin/perl -w use strict; use Data::Dumper; if( fork ) { require Win32::MMF::Shareable; my $ns = tie( my %share, 'Win32::MMF::Shareable', 'share' ) || die; sleep(1); $share{parent} = 1; print Dumper(\%share); } else { require Win32::MMF::Shareable; my $ns = tie( my %share, 'Win32::MMF::Shareable', 'share' ) || die; $share{child} = 1; }

Is this because the require is executed at run-time, which causes two different copy of Storable to be loaded at run-time, which in turn gets freed properly in their own instances?

And thanks again!

Replies are listed 'Best First'.
Re: Re: Re: Perl forking and shared memory strangeness under Windows
by BrowserUk (Patriarch) on Feb 23, 2004 at 08:12 UTC
    Is this because the require is executed at run-time, which causes two different copy of Storable to be loaded at run-time, which in turn gets freed properly in their own instances?

    Yes. YW :)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Timing (and a little luck) are everything!