Memory leak in SBJsonStreamWriter #80

DinosaurDad opened this Issue Jun 19, 2011 · 0 comments

2 participants


In the current implementation of SBJsonStreamWriter, there is a leak that stems from the init method.

- (id)init {
    self = [super init];
    if (self) {
        maxDepth = 32u;
        stateStack = [[NSMutableArray alloc] initWithCapacity:maxDepth];
        state = [[SBJsonStreamWriterStateStart alloc] init];
    return self;

The problem is the assignment of state to an alloc that never gets released (the property is assign, not retain). If I use state = [SBJsonStreamWriterStateStart sharedInstance]; instead, the leak goes away. With some fair amount of unit testing I haven't seen any side effect.

In light of issue #79, perhaps the fix for the __weak state property could address this as well?

@stig stig closed this in 064d37d Jun 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment