Cees Hek wrote:
> On 10/3/05, Michael Peters <[EMAIL PROTECTED]> wrote:
>
>>Memory will only get unshared if it's written to. So it's quite possible
>>that there are a lot of modules out there that will change package level
>>variables, etc and thus unshare a page. But I don't think this is a perl
>>issue, but rather the author's of those modules not thinking about
>>shared memory.
>
>
> I believe that if you use lexicals for all your variables, you should
> be OK (so always use 'my'). If you alter variables configured with
> 'use vars' or 'our' then pages start becoming unshared very quickly.
I don't think this is the case. I'm pretty sure it has to do with the
variables scope not necessarily with the method of declaration (lexical
or not). You can still declare package scoped variables with 'my', they
just aren't accessible from the outside.
For instance:
package Foo;
my $bar
...
sub set_bar {
$bar = shift;
}
1;
If set_bar() is called $bar will become unshared and thus the whole page
of memory containing this perl code will become unshared (unless of
course if set_bar() is called at compile time in a BEGIN block). So any
packages that try to maintain state will probably have this problem
unless they use some outside mechanism. Notice I said 'packages', not
'objects'.
--
Michael Peters
Developer
Plus Three, LP
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]