I am running into a memory issue when running my UI automated tests with XCTestCase in iOS 9. When I launch my UI tests I see two processes get kicked off in xcode, one for the app I am testing and one for the actual UI tests. My app's memory stays around 60 MB, but the UI test grows to around 400 MB before the device kills it for using too much memory. My UI test is pretty simple, where I am just tapping buttons as I go through a test in my app. All of the code looks similar to this, though I go through about 30 questions:
app.buttons["next question button"].tap() // Move to the next question
app.staticTexts["Correct answer text"].tap() // Select the correct answer
At first I thougth that maybe it was how I was doing asserts, since I was using waitForExpectationsWithTimeout. But taking these out doesn't seem to have any effect. It's seems like as my UI updates (and my app UI is going through a lot of views, it is a VERY visual testing app) the XCUIElementQuery items may be keeping track of the entire UI history. So, as my app creates new elements the RAM usage of the UI test skyrockets. See below for an example of what I am seeing in XCode:
Does anyone know of anyway to reset/release this memory? Reinitializing let app = XCUIApplication() doesn't seem to do anything. Or does this seem like a memory leak in the UI automation framework?