Forum Discussion

chehs01's avatar
chehs01
Occasional Contributor
10 years ago

SOAPUI XmlSlurper memory leak?

Hi,

 

I have SOAPUI 5.0 installed. My SOAPUI groovy script reads a 18 MB xml file and retrieve xml elements using XMLSlurper. I am seeing the SOAPUI exe grows every time I run the script. It can grow from 30 MB to 100 MB or more... Anyone know what can cause the leak?

 

This is my script

import groovy.io.FileType

def list = []

def dir = new File("C:\\TEV\\results\\")
dir.eachFileRecurse (FileType.FILES) { file ->
 if (file=~'.xml'){
   f = file.toString().replaceAll("C:\\\\TEV\\\\results\\\\","")
   list << f.toString().replaceAll(".xml","")

 }
}

 

  list.each{fund->
   def xml = new File( "C:\\TEV\\results\\${fund}.xml" )
   def root = new XmlSlurper().parse(xml)
//   def root = new XmlParser().parse(xml)
   root.holdingGroupList.holdingGroupByWeights.each{hg->

    if (hg.holdingGroupName ==fund){
     log.info ( "${fund} NOTIONAL: ${hg.portfolioValue}")
     def bucket = hg.customBucketList.customBucket
     bucket.each{b ->
      if (b.customDimensionName == 'attribEffect')
       log.info ( "${fund} TAG: ${b.customBucketValue}")
     }
    }
   }

  }

 

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    How many files are in the directory that your scripts scans? Are they all 18Mb?

     

    The first part of the script looks fairly innocent i.e. create a list of all file names in the directory.

     

    For the sceond part of the script, I wondered whether moving the creation of new XmlSlurper() out of the loop would make a difference to the memory usuage? e.g. something like

     

    XmlSlurper slurper = new XmlSlurper()

    list.each{fund->
       def xml = new File( "C:\\TEV\\results\\${fund}.xml" )
       def root = new slurper.parse(xml)

    ...

     

    Regards,

    Rupert

    • chehs01's avatar
      chehs01
      Occasional Contributor
      Hi,

      I am only placing 1 file in the folder. Also I tried only run this statement. Soapui still memory leaks.

      XmlSlurper slurper = new XmlSlurper()
      list.each{fund->
      def xml = new File( "C:\\TEV\\results\\${fund}.xml" )
      def root = new slurper.parse(xml)
      ...