Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove unnecessary finalizers #330

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

Closed
wants to merge 2 commits into from
Closed

Conversation

sharwell
Copy link
Contributor

This class does not own any unmanaged resources, so adding a finalizer increases GC overhead for the class without any benefits. The GitObjectSafeHandle already provides guaranteed cleanup.

@sharwell
Copy link
Contributor Author

I added a second commit to this. The finalizer in Repository was unnecessary as well.

@nulltoken
Copy link
Member

Hey @sharwell, thanks a lot for bringing this on the table. Both Joe Duffy and Stephen Toub seem to back up this proposal.

@phkelley @xpaulbettsx Any opinion?

@anaisbetts
Copy link
Contributor

@nulltoken Full ✨, only classes that directly have to free handles or memory should have finalizers. Finalizers are CrazyTown™ and should be avoided unless they're definitely needed

@nulltoken
Copy link
Member

@sharwell Full ✨ then!

✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨

Thanks a lot for your recent contributions. Merged!

@nulltoken nulltoken closed this Feb 14, 2013
@sharwell sharwell deleted the rm-finalizer branch February 14, 2013 22:38
@dahlbyk
Copy link
Member

dahlbyk commented Feb 18, 2013

After this change I'm seeing a bunch of warnings for Proxy.git_commit_create():

  A GitObjectSafeHandle handle wrapper has not been properly disposed.
     at LibGit2Sharp.Core.NativeMethods.git_object_lookup(GitObjectSafeHandle& obj, RepositorySafeHandle repo, GitOid& id, GitObjectType type)
     at LibGit2Sharp.Core.Proxy.git_object_lookup(RepositorySafeHandle repo, ObjectId id, GitObjectType type) in c:\Dev\GitHub\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 948
     at LibGit2Sharp.Core.ObjectSafeWrapper..ctor(ObjectId id, RepositorySafeHandle handle, Boolean allowNullObjectId) in c:\Dev\GitHub\libgit2sharp\LibGit2Sharp\Core\ObjectSafeWrapper.cs:line 21
     at LibGit2Sharp.Core.Proxy.<>c__DisplayClassa.<git_commit_create>b__6(ObjectId id) in c:\Dev\GitHub\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 256
     at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
     at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
     at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
     at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
     at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
     at LibGit2Sharp.Core.Proxy.git_commit_create(RepositorySafeHandle repo, String referenceName, Signature author, Signature committer, String prettifiedMessage, Tree tree, IEnumerable`1 parentIds) in c:\Dev\GitHub\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 263
     at LibGit2Sharp.ObjectDatabase.CreateCommit(String message, Signature author, Signature committer, Tree tree, IEnumerable`1 parents, String referenceName) in c:\Dev\GitHub\libgit2sharp\LibGit2Sharp\ObjectDatabase.cs:line 158

@nulltoken
Copy link
Member

I think @yorah has a fix for these.

Something about the parents of the commits being enumerated twice but disposed only once.

@sharwell
Copy link
Contributor Author

This commit did not cause those warnings, but rather prevented code from incorrectly suppressing the warnings which should have been reported the whole time.

@nulltoken
Copy link
Member

@sharwell I know. Thanks for helping us putting those under the light ❤️

@dahlbyk
Copy link
Member

dahlbyk commented Feb 18, 2013

I didn't mean to suggest you had caused them, I just wanted to make sure I wasn't the only person that had noticed. 😊

@sharwell
Copy link
Contributor Author

I never take things like that personally. You did track the message down to a relevant commit; I merely gave you the next link in the chain to follow. :)

@yorah
Copy link
Contributor

yorah commented Feb 19, 2013

Yes, I have a few fixes for those messages coming up in another PR (hopefully today).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants