Project

Profile

Help

Bug #6306

Updated by O'Neil Delpratt 11 months ago

Saxon in python is not releasing memory. 

 I am trying to use Saxonche in python for XSLT2.0 transformation. 

 I am using the below code in a for loop in my django project, it is providing the expected output but it is consuming a lot of memory and the memory is not getting released, because of which the container is getting restarted. I have tried searching the saxonica documents but unable to find the root cause or fix this issue.  

 ``` python 
 from saxonche import * 
 with (PySaxonProcessor() as proc): 
 xslt_process = proc.new_xslt30_processor() 
 document = proc.parse_xml(xml_text=dom) # Load the XML document 
 stylesheet = xslt_process.compile_stylesheet(stylesheet_file=xsl_file_path) # Compile the XSLT stylesheet 
 # Apply the transformation 
 input_xslt = stylesheet.transform_to_string(xdm_node=document) 

 # cleaning string which we got from XSLT 
 input_xslt = ''.join(input_xslt.split("\n")).replace("</output1>", '') 
 input_xslt = input_xslt.replace("<output1>", '').strip() 
 input_xslt = input_xslt.replace('<?xml version="1.0" encoding="UTF-8"?>', '').strip() 
 input_xslt = [x.strip() for x in input_xslt.split(",")] 
 return input_xslt 
 ``` 


 

Back