Skip to content

Commit

Permalink
Resolve Memory Leak (#113)
Browse files Browse the repository at this point in the history
- Cleared the reader before marking it unused

Co-authored-by: Martin Hickson <mhickson@bravurasolutions.com>
  • Loading branch information
2 people authored and kubycsolutions committed Nov 27, 2023
1 parent a5ff54c commit 3689380
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/org/apache/xml/utils/XMLReaderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,15 @@ public synchronized XMLReader getXMLReader() throws SAXException {
* @param reader The XMLReader that's being released.
*/
public synchronized void releaseXMLReader(XMLReader reader) {
if (reader == null) {
return;
}
// If the reader that's being released is the cached reader
// for this thread, remove it from the m_isUse list.
if (m_readers.get() == reader && reader != null) {
m_inUse.remove(reader);
// for this thread, mark it as no longer being in use.
if (m_readers.get() == reader) {
m_readers.set(null);
m_inUse.put(reader, Boolean.FALSE);
}
m_inUse.remove(reader);
}
}

2 comments on commit 3689380

@chiragsanghavi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinhickson @kubycsolutions Thank you for authoring these. Would you know if these will be part of a build made available for download?

@kubycsolutions
Copy link
Contributor

@kubycsolutions kubycsolutions commented on 3689380 Dec 12, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.