This is a discussion on Re: mod_perl2 and Apache::SharedMem - modperl ; On Nov 7, 2007 5:50 PM, Boysenberry Payne wrote: > If I created some of my static hashes and objects during the > PerlPostConfigHandler phase > and added them to either the configuration or log pools You're missing the big ...
On Nov 7, 2007 5:50 PM, Boysenberry Payne
> If I created some of my static hashes and objects during the
> PerlPostConfigHandler phase
> and added them to either the configuration or log pools
You're missing the big picture. Adding perl objects to a shared
memory pool doesn't prevent them also needing to be in perl's own
allocated memory pool. All shared memory schemes with perl result in
MORE memory being used, because every process that accesses these
structures needs its own copy in its own process in addition to the
shared one. The shared memory one is a serialized perl structure,
created with something like Storable and perl has to turn it back into
a normal perl variable, in non-shared memory, in order to use it.
You can't use less memory by sharing your perl data with user-level
shared memory techniques. Only copy-on-write can help with that.
> I have classes that create singleton objects with lots of static
> parts. Should I build these "constructs"
> on server post config so they're already built in the child processes
> as shared memory rather than
> building them in each child, increasing the non-shared memory use?
Build them before the server forks if you use prefork.
> Would it allow me to reduce what I have set for
You shouldn't be using that at all unless you have Linux::Smaps
installed, but if you do, loading things before forking should improve
the amount of copy-on-write sharing.