I have never used Openssl, but for libxml, as far as I remember either it returns the memory (the document tree) to the caller, or the caller has to do new/free calls like for newcontext paired with freecontext.
To share some resource between plugins reference count it and have plugins free their reference when they are done with it or are exiting.