Thanks. I realize now that this is covered in the FAQ. I actually do have
a need to initialize and terminate the utilities multiple times in a single
process. I have several different libraries that use Xerces-C, each needing
to initialize the platform utilities individually. I use these libraries in
the same process in a way such that instances of the classes using Xerces-C
do not exist at the same time. The classes from the first library are
instantiated and used (and freed), resulting in initialization and
termination of the Xerces-C utilities. Then the classes from the next
library are instantiated and (and freed) resulting in an attempt to
initialize the Xerces-C utilities which results in an error.
The only way I've seen to get around this limitation is to have the owning
process explicitely do the initialization and termination of the Xerces-C
utilities. I do not like this at all, however, since it forces me to expose
Xerces-C to the client of multiple libraries that use Xerces-C (even though
the client code has no direct need for Xerces-C).
I guess this issue only comes up in large systems where multiple libraries
(within the same process) will need to completely manage Xerces-C
independent of each other. Are there any plans to allow this kind of use of
Xerces-C?
Thanks,
Ray
-----Original Message-----
From: Dee Jay Randall [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 07, 2001 4:21 PM
To: [EMAIL PROTECTED]
Subject: Re: Problem initializing and terminating XMLPlatformUtils more
than o nce in a program
The API doc says:
"void XMLPlatformUtils::Initialize () [static]
Perform per-process parser initialization."
so I assume it isn't mean to be called repeatedly.
It is also written at http://xml.apache.org/xerces-c/program.html
"Key points to remember when using the C++ DOM classes:
- Create them as local variables, or as member variables of some
other class. Never "new" a DOM object into the heap or make an
ordinary C pointer variable to one, as this will greatly confuse
the automatic memory management. "
So that might be your problem.
You should just create your parser like:
DOMParser myDOMParser;
and you don't need to delete it. If you really want two of
them with the same name, you can put them in their own code
blocks with {}.
I thought I noticed a similar problem in my own project
without using new. It went away when I moved my call to
XMLPlatformUtils::Terminate() to where it would only occur
once. (As it happens I am happily calling XMLPlatformUtils::Initialize()
multiple times with no apparent problems. I will be making that
go away shortly.)
Dee Jay
+-----------------------------+------------------+-----------------------+
| Founding Partner | Software Engineer| Dee Jay Randall, B.Sc.|
| Circular Reasoning | Accrue Software | M.Sc. Student, CS |
| [EMAIL PROTECTED]| www.accrue.com | ICQ # 43551676 |
+-----------------------------+------------------+-----------------------+
What is the average rank of every song ever written? 42 -- www.launch.com
On Mon, May 07 2001 at 03:00:30P -0700, Mitchell, Raymond wrote:
> I have run into a problem attempting to initialize and terminate
> XMLPlatformUtils more than once in a single program. The following code
> causes the error.
>
> XMLPlatformUtils::Initialize();
> DOMParser *pDOMParser = new DOMParser;
> delete pDOMParser;
> XMLPlatformUtils::Terminate();
> XMLPlatformUtils::Initialize();
> pDOMParser = new DOMParser; // Error occurs here
> delete pDOMParser;
> XMLPlatformUtils::Terminate();
>
> The error message indicates that an illegal memory access has occured.
The
> stack trace indicates that the error is occuring when trying to obtain the
> XMLMutex while constructing the XMLScanner. Here is the stack trace:
>
> NTDLL! 77f8aa57()
> XMLMutex::lock() line 117 + 11 bytes
> XMLMutexLock::XMLMutexLock(XMLMutex * const 0x007a7b50) line 135
> XMLScanner::commonInit() line 784 + 14 bytes
> XMLScanner::XMLScanner(XMLValidator * const 0x007a7f90) line 162
> DOMParser::DOMParser(XMLValidator * const 0x00000000) line 123 + 41
> bytes
> main(int 2, char * * 0x007a1870) line 182 + 46 bytes
>
> Is it supposed to be possible to initialize and terminate the
> XMLPlatformUtils more than once in a single program, or does calling
> XMLPatformUtils::Terminate() cause future calls to
> XMLPlatformUtils::Initialize() only to appear to work?
>
> Thanks,
> Ray
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]