forked from jasder/antlr
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:
parent
d0c9744305
commit
555c14956a
|
@ -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.
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
Loading…
Reference in New Issue