Title: Enable pythonnet to survive in the Unity3d editor environment. by benoithudson · Pull Request #752 · pythonnet/pythonnet · GitHub
Open Graph Title: Enable pythonnet to survive in the Unity3d editor environment. by benoithudson · Pull Request #752 · pythonnet/pythonnet
X Title: Enable pythonnet to survive in the Unity3d editor environment. by benoithudson · Pull Request #752 · pythonnet/pythonnet
Description: The Unity editor unloads the C# domain and creates a new domain every time it recompiles C# sources. This caused two crashes. After a domain unload, python is now pointing to a bunch of objects whose C# side is now garbage. Solution: Shutdown() the engine on domain reload, which calls Py_Finalize. After a domain unload, Py_Finalize, and a new Py_Intialize, python still keeps pointers in gc for any python objects that were leaked. And pythonnet leaks. This means that python's gc will be calling tp_traverse, tp_clear, and tp_is_gc on types that are implemented in C#. This crashes because the implementation was freed. Solution: implement those calls in code that is not released on domain unload. Side effect: we leak a page on every domain unload. I suspect but didn't test that python gc performance will be slightly faster. Changes required to implement and test: 3. Use python's platform package to determine what we're running on, so we can use the right mmap/mprotect or VirtualAlloc/VirtualProtect routines, the right flags for mmap, and (theoretically) the right native code. Side effect: to port to a new platform requires updating some additional code now. New unit tests. (a) A new test for domain reload. It doesn't run under .NET Core because you can't create and unload a domain in .NET Core. (b) New unit tests to help us find where to add support for new platforms. Does this close any currently open issues? #714 ; see also #745 and #751.
Open Graph Description: The Unity editor unloads the C# domain and creates a new domain every time it recompiles C# sources. This caused two crashes. After a domain unload, python is now pointing to a bunch of objects w...
X Description: The Unity editor unloads the C# domain and creates a new domain every time it recompiles C# sources. This caused two crashes. After a domain unload, python is now pointing to a bunch of objects w...
Opengraph URL: https://github.com/pythonnet/pythonnet/pull/752
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:582215b8-7315-ebd9-0e0e-617384b7768f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BB62:3E883C:2C41C4:3A7346:6972DBE5 |
| html-safe-nonce | fa6e8844ce6862123d5c087388ad1cd25200174b11e67129e0853ef85bd7ac87 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjYyOjNFODgzQzoyQzQxQzQ6M0E3MzQ2OjY5NzJEQkU1IiwidmlzaXRvcl9pZCI6IjExMzk4ODI4NDAzNjM4MTc5NTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6130cb13161a2e251327362c08f1e7dc58abd1fe312f48b90d04a88f488b992c |
| hovercard-subject-tag | pull_request:222575536 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/pythonnet/pythonnet/pull/752/files |
| twitter:image | https://avatars.githubusercontent.com/u/15807877?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/15807877?s=400&v=4 |
| og:image:alt | The Unity editor unloads the C# domain and creates a new domain every time it recompiles C# sources. This caused two crashes. After a domain unload, python is now pointing to a bunch of objects w... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0b28c359b13f980b4fbede8da4d68e72b8e69a4837e7a70f5b5bd33f08875133 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e59d75213c810b4a9ea72ce3aa89d45f5b2feb48 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width