MockService out of heap memory when deployed as War
I created a mock service that reads large XML files, replaces a ${content} token and sends a response. Each file is about 6mb.
I increased my heap size in SoapUI and it works fine in there. Memory increases until the heap max, but it continues to run without error.
If I deploy the same mock service as a war and run it in Tomcat with catalina_opts set to double the heap size, it quickly runs out of memory.
I have already removed all log.info statements from the script. How can I fix the memory leak?
I can't send the entire script at the moment, but the meat of it reads a value from the request and then finds a file with that name:
def projectPath = new File(mockOperation.mockService.project.path).parent def fileName = projectPath + "${File.separator}dataFiles${File.separator}${requestValue}.xml" def file = new File(fileName) if (file.exists()) { context.content = file.text return "FromFile" } else { return "Empty" }
Answering my own question. Analysis of the problem shows that property expansion is causing a memory leak. I modified the mockService moving the code from the mockOperations to the OnRequestStart event.
Instead of using property expansion with context.content = file.text, I did the following to return the file contents:
def result = new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest) def file = new File(fileName) mockRequest.httpResponse.writer << file.text mockRequest.httpResponse.status = 200 return result