You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Da...@lotus.com on 2000/08/31 20:27:25 UTC

[Xalan-C] Important code changes!!!

Hi All,

This afternoon, I will be checking changes to Xalan-C so that static data
is initialized and terminated explicitly.  This will allow for better
memory-leak detection, and for better end-user control over Xalan-C.  In
addition, we have plugged all known memory leaks, and we will be doing
extensive testing to determine if there are any left in the code.

The only change that will need to be made to user code is to create an
instance of an initializer object before you create any instances of Xalan
classes.  All of the sample, TestXSLT, and TestXPath have been updated to
reflect this change.  Although we have yet to test multiple initialization
and termination of Xalan, we plan to support the ability to do so.  For
now, I'm not sure how useful this will be, since Xerces can be
re-initialized after it is terminated, but I believe there are plans to
change that in the future.

Each subsystem which requires initialization now has a class that will
initialize the subsystem in its constructor, and terminate the subsystem in
its destructor.  There is a static count kept, so there is no problem with
multiple initializations, but modification of the count is not done in a
thread-safe manner.  This is by design -- we will not support the use of
synchronization objects within the core of Xalan.  If you which to use
multiple initialization objects, you will need to manage synchronization
yourself.  In most cases, you can just create an initializer before you
start multi-threaded execution.  The initializer object for a given
subsystem will _automatically_ initialize any subsystems that it uses.
Since most people are using all of Xalan, you only need to create an
XSLTInit instance.

You must initialize Xerces before you create the Xalan-C initializer, and
make sure that the Xalan-C initializer is destroyed before you terminate
Xerces.  The easiest way to do this is by introducing a new scope before
you create the initializer instance:

   int
   main()
   {
       XMLPlatformUtils::Initialize();

       {
           XSLTInit    theInit;

           ...
       }

       XMLPlatformUtils::Terminate();
   }

For those using the Win32 platform, the debug builds of TestXPath and
TestXSLT will dump memory leaks when the application terminates.  Please
post to the list if you see any of these dumps. This will not work if you
are using the ICU with Xerces, or you are using Xalan's ICU integration,
since the ICU does not yet allow for explicite destruction of static data.

If anyone is aware of any open-source utilities for doing these sorts of
checks on Linux, or Unix platforms, please let me know.  We would like to
have the same ability on the other platforms.

Comments, questions?

Dave