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

[MediaContent] Wrong Implement of Dispose pattern #70

Closed
myroot opened this issue Jan 23, 2018 · 4 comments
Closed

[MediaContent] Wrong Implement of Dispose pattern #70

myroot opened this issue Jan 23, 2018 · 4 comments
Assignees

Comments

@myroot
Copy link
Contributor

myroot commented Jan 23, 2018

protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
_handle.Free();
}
disposedValue = true;
}
}

_handle should be always freed.

https://msdn.microsoft.com/ko-kr/library/system.runtime.interopservices.gchandle(v=vs.110).aspx
When the handle goes out of scope you must explicitly release it by calling the M:System.Runtime.InteropServices.GCHandle.Free method; otherwise, memory leaks may occur. When you free a pinned handle, the associated object will be unpinned and will become eligible for garbage collection, if there are no other references to it.

@myroot
Copy link
Contributor Author

myroot commented Jan 23, 2018

Of course, this object always uses Dispose, so there is no real problem.

@coderhyme
Copy link

You mean the problem is when the disposing value is false. Right?

@myroot
Copy link
Contributor Author

myroot commented Jan 24, 2018

Yes, the disposing value was false when disposed by finalizer and in this case _handle was not released

@coderhyme
Copy link

coderhyme commented Jan 25, 2018

Has been fixed by #81.

TizenAPI-Bot added a commit that referenced this issue Aug 26, 2020
shyunMin pushed a commit that referenced this issue Dec 12, 2023
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

No branches or pull requests

2 participants