Skip to content
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

All subclasses of OCMockObject should get stopMocking called on them in dealloc #497

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions Source/OCMock/OCClassMockObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ - (id)initWithClass:(Class)aClass
return self;
}

- (void)dealloc
{
[self stopMocking];
[super dealloc];
}

- (NSString *)description
{
return [NSString stringWithFormat:@"OCClassMockObject(%@)", NSStringFromClass(mockedClass)];
Expand Down
2 changes: 1 addition & 1 deletion Source/OCMock/OCMockObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ - (instancetype)init

- (void)dealloc
{
[self stopMocking];
[stubs release];
[expectations release];
[exceptions release];
[invocations release];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of not releasing the invocations array?

Copy link
Contributor Author

@dmaclach dmaclach Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it happens in -stopMocking and that I probably thought this was redundant.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell this is the only place.

https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/erikdoe/ocmock%24++%5Binvocations+release%5D&patternType=structural

Removing it here would leak the invocations.

No need to fix on your end, I'll do it while merging.

[super dealloc];
}

Expand Down