On Monday, Feb 24, 2003, at 19:47 Europe/London, Jim Morrison [Mailing-Lists] wrote:

What I thought was that if I kept the handle to the parsed XML open
somewhere else then I would be able to use it.. so a separate process
does the parsing and keeps hold of the handles of the currently 'shared'
bits of XML.. What comes out the other end is something along the lines
of:


bless( do{\(my $o = 137110200)}, 'XML::LibXML::Document' )

But trying to toString() it for instance gives me a :

        XML::LibXML::Document::_toString() -- self contains no data at
[snip]/LibXML.pm line 659.

To what does the "my $o = 137110200" refer?  Is there no way I can get
the parsed object out of LibXML2 into another process?

It's a pointer to a region of memory. Since you have protected memory in your operating system, only the process that malloced that region of memory can access it, hence you can't access it from another process. And no, you can't make XML::LibXML allocate in shared memory.


The only conceivable way you could do it is create the DOM before the fork and rely on copy-on-write.

CAVEAT : I know it's probably looked at as a silly idea, but if I could
keep my parsed stylesheets/xml's shared somewhere I'd save my self
having to re-parse for every request wouldn't I? . .

Before you try this, *please* investigate parsing every time your output needs to change (caching a-la AxKit). A very large site I know tried this and discovered that XML::LibXML/LibXSLT parses stylesheets *so* fast that it made zero difference to them to cache the stylesheets in memory (shared or otherwise).


Try it. You may discover you don't need all this caching.

Matt.



Reply via email to