-
Notifications
You must be signed in to change notification settings - Fork 750
Release method wrapper(split from #958) #1002
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1002 +/- ##
=======================================
Coverage 86.71% 86.71%
=======================================
Files 1 1
Lines 301 301
=======================================
Hits 261 261
Misses 40 40
Continue to review full report at Codecov.
|
bool shouldFreeDef = Runtime.Refcount(py_clr_module) == 1; | ||
Runtime.XDecref(py_clr_module); | ||
py_clr_module = IntPtr.Zero; | ||
#if PYTHON3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid introducing another compile-time check, and use version info from Runtime
class instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, in the modernisation branch I gave up on the idea of having Python 2 and 3 in the same codebase, especially considering the imminent EoL of Python 2. I do that by defaulting to Python 3 and letting the user supply PYTHON2
explicitly for the Py2 version. So here, to stay in line with that, it would be enough to change to #if !PYTHON2
.
bool freeDef = Runtime.Refcount(ptr) == 1; | ||
Runtime.XDecref(ptr); | ||
if (freeDef && mdef != IntPtr.Zero) | ||
{ | ||
Runtime.PyMem_Free(mdef); | ||
mdef = IntPtr.Zero; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we call Release
, and there are still references to the method, how is it going to be freed later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amos402 Could you comment on this question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't release anymore, here's the only chance for now. Assume the ptr deallocating in another domain in the future, the cod in this domain had already been invalid, unless we use a C extension take place the ptr's tp_dealloc
.
* Add exception helper * Release memory on ImportHook.Shutdown * Release ModuleDef when py_clr_module released * Completely ModuleDef initialization
What does this implement/fix? Explain your changes.
Release method wrapper and module definition(Python3) when shutdown
Does this close any currently open issues?
...
Any other comments?
...
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG