-
-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak fix & more sanitization in tests #270
Conversation
Does this fix #268?
Hey @pcantrell! Thanks so much for jumping on this. I'm planning to release a new version of my app this week, and I had included 1.4.0 in it. Would you recommend using |
I'm trying to setup Siesta so I can build and run the tests on my local machine, but I'm unable to get Carthage to compile Nocilla, I'm getting the following error:
If I'm reading that right, it wants a tvOS simulator which is version 11.4, but since I'm not yet on Xcode 10, I only have access to devices up to 11.3. Any suggestions on how to fix? |
I expect that the memory_leak branch should be safe, but I’d love to see it pass CI before I say that with confidence. I’d happily welcome any additional detective work on this! This PR’s new leak check in the tests is flagging leaks with the Alamofire provider. The problem is puzzling, and I haven't yet figured out whether it’s real or whether Alamofire just delays cleanup of its requests in a way that trips the test but is actually harmless. If you want to take a look and puzzle over it, run the tests with the env var You can see the AF issue in the Siesta macOS target, which runs much faster than the others because it doesn’t require a simulator. The check that’s failing just keeps a weak ref to each test case’s
Could you open a separate issue for this? Then we can tag in the kind person who contributed the tvOS support. |
Update: my current working theory is that AF is relying on autorelease for cleanup, and the autorelease pool doesn’t get drained until after my |
Yes, confirmed: at least some of the tests pass with Alamofire if each spec is wrapped in The problem now is that AFAICT, Quick doesn’t provide any sort of I have to dash off, and will be on other tasks most of the rest of the day. @jordanpwood, if you have some time today, you could help by investigating whether it’s possible to control autorelease pools with Quick. We need some way to make sure that each spec created during this call gets wrapped in its own pool, and that the pool is drained before the leak-checking block runs. The solution I’d want, but don’t know if Quick supports, would look like this: aroundEach
{
spec in
autoreleasepool
{ spec() } // (1)
}
afterEach
{
// (2) …check for leaks here…
} …so that the order of execution is:
|
Trying a Quick fix (pun intended) for the Alamofire tests. If it passes CI, we’ll see if Quick wants to accept the new feature…. |
It's almost passing the tests, are those leaked services real, or is it more test artifacts? |
Fixes sporadic false leaks failures, esp using Alamofire
AF sometimes attached bonus items to userInfo
Phew, passed! It was test artifacts, it seems — though establishing that and working around them took some finagling. The general flavor of all these leak-checking issues is that between Siesta, URLSession, and Alamofire, there’s a lot of deferred cleanup, and some of it is timing-sensitive. I hacked around it by adding a very forgive progressive delay-and-retry loop before we confirm the leak. The good news is that the wait-and-rety appears to also take care of the nasty Travis issues that the unpleasant |
Fixes #268.
Adds a basic check for leaked
Service
(and thusResource
) instances to the test suite.Enables assorted Xcode sanitization options in tests.
Fixes several unimportant but now-detected leaks & thread issues in the tests.