Fix retain cycle between Parser and ParserATNSimulator.

This was causing the entire parser to be retained, resulting in a large
memory leak.

This fix simply changes the reference from ParserATNSimulator to Parser
to be unowned.

Ditto between Lexer and LexerATNSimulator, except this reference is made
weak because LexerATNSimulator.recog is nullable.  (That difference is
dubious IMHO, but I'm leaving it intact for now.)
This commit is contained in:
Ewan Mellor 2017-10-21 15:44:33 -07:00
parent d0c9744305
commit 555c14956a
No known key found for this signature in database
GPG Key ID: 7CE1C6BC9EC8645D
2 changed files with 3 additions and 2 deletions

View File

@ -50,7 +50,7 @@ open class LexerATNSimulator: ATNSimulator {
}
internal let recog: Lexer?
internal weak var recog: Lexer?
///
/// The current token's starting index into the character stream.

View File

@ -250,7 +250,8 @@ open class ParserATNSimulator: ATNSimulator {
}
return false
}()
internal final var parser: Parser
internal final unowned let parser: Parser
public final var decisionToDFA: [DFA]