-
Notifications
You must be signed in to change notification settings - Fork 1
Reworked ManagedType
to not keep python references to self
#2
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
Reworked ManagedType
to not keep python references to self
#2
Conversation
978fd25
to
78fc99d
Compare
…beMethodBase contains no method
they are no longer needed as ClassBase instances no longer hold Python references to themselves
78fc99d
to
78a18ba
Compare
78a18ba
to
1a4ada7
Compare
…ype instances, unless they are per-alloc call no problem though - they will be collected by .NET garbage collector eventually
…cted directly instead. Also fixes event_rename domain reload test case
it should not be possible to construct an instance of a class that has been unloaded
04b5d9e
to
fd36721
Compare
fd36721
to
cb58147
Compare
removed debug code, that ensured Python GC list integrity
69be9b2
to
a8ef06c
Compare
… to allow them to be garbage collected
…ht shut down and unload corresponding methods before Python terminates
@filmor this seems to be working (at least tests are passing). The diff starts on top of pythonnet#1603 I wish it were smaller, but the old code that supported app domains for 3.8 and below just does not work for 3.9 and 3.10 (it made assumptions about internal GC data structures, that are no longer valid). |
fad8f0b
to
d6edace
Compare
namespace Python.Runtime; | ||
|
||
[Serializable] | ||
internal class EventHandlerCollection: Dictionary<object, List<Handler>> |
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.
mostly moved from eventobject.cs
remote analyzer workaround
} | ||
|
||
private static void ResotreModules(IntPtr dummyGC) | ||
private static void ResotreModules() |
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.
Typo
Remove
pyHandle
andtpHandle
fields inManagedType
which used to make instances ofManagedType
self-referential.ManagedType
now providesAlloc
, that creates a Python wrapper around the instance and returns a strong reference to it. That reference is explicitly passed around everywherepyHandle
was needed (usually asBorrowedReference ob
).With reference loops gone (one notable exception is
PythonDerivedType
that still requires it for .NET to be able to access Python implementation and vice versa), reference tracking is simplified. Lists of all wrapped .NET objects is stored inCLRObject.reflectedObjects
and all extension types inExtensionType.loadedExtensions
for cross-domain support replacing "track types".PyObject
disposal and finalization andPythonDerivedType
finalization have been reworked to permit them when and only when both Python runtime and Python.NET engine are in appropriate states.A few minor bugs were fixed.