apollo-ios: Lots of small memory leaks
I’m using codegen 0.18.8 and Apollo 0.8.0 and noticing a huge amount of leaks using the Debug Memory Graph tool. Each of them is 32 bytes and I have 1313 of them, so ~42kb in leaks.
It looks like this all comes from some static selections:
public static let selections: [GraphQLSelection] = [ /* ... */ ];
Is this a concern? If anything, it’s eating up a ton of UI when debugging cycles (lots of “load more”). Any tips for working around this?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 29
- Comments: 29 (11 by maintainers)
It’s been more than year and this issue is still there 😦 IMO it’s a serious problem - after using app for few minutes with each api call memory usage increase enormously
Is this really a memory leak? As those are static variables this is bounded by the number of classes right? Well maybe each parent type is duplicating the objects its compute from its children?
Would changing
to
on children types solve the issue?
This has, at long last, shipped with
0.29.0
.Thanks to everyone for your patience on this and particularly to @gsabran for spotting the real underlying issue.
If you implement it as a computed var (not a lazy var), there is no possibility to set a value.
I think the problem is related to accessing
resultHandlers
inside lock closures.https://github.com/apollographql/apollo-ios/blob/master/Sources/Apollo/Promise.swift#L217 https://github.com/apollographql/apollo-ios/blob/master/Sources/Apollo/Promise.swift#L229