-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[mono][interp] Fix various leaks, primarily around dynamic methods #119176
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
For dynamic methods, imethod_alloc0 allocates from the dynamic method's mempool which is freed when the method is collected. We were previously allocating only from the global memory manager.
|
Tagging subscribers to this area: @BrzVlad, @kotlarmilos |
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.
Pull Request Overview
This PR addresses memory leaks in the Mono interpreter, particularly for dynamic methods. The main focus is on properly freeing method headers created during inlining operations and making various data structures associated with dynamic methods freeable.
Key changes:
- Tracks and frees method headers created during inlining to prevent memory leaks
- Changes memory allocation strategy for offset arrays to use freeable memory
- Implements cleanup of tiering data and patch sites when dynamic methods are freed
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/mono/mono/mini/interp/transform.h | Adds headers_to_free field to track method headers for cleanup |
| src/mono/mono/mini/interp/transform.c | Implements header tracking and changes allocation strategy for offset arrays |
| src/mono/mono/mini/interp/tiering.h | Adds function declaration for clearing data items patch sites |
| src/mono/mono/mini/interp/tiering.c | Implements cleanup logic for patch sites when dynamic methods are freed |
| src/mono/mono/mini/interp/interp.c | Integrates patch site cleanup into method freeing process |
| src/mono/mono/mini/interp/interp-internals.h | Adds n_data_items field to track data item count for cleanup |
Previously we were registering imethod locations from these data items in order for them to be patched once a method is tiered up. Because of this registering, the data item had to always be around. We now free the data item for dynamic methods and also we deregister the patch locations when freeing such a method.
We add them to a list for later freeing. This uses the same pattern as jit.
1d27a95 to
6004983
Compare
|
can you backport to release/9.0 and release/10.0 branch |
…otnet#119176) * [mono][interp] Fix leaking of compilation data For dynamic methods, imethod_alloc0 allocates from the dynamic method's mempool which is freed when the method is collected. We were previously allocating only from the global memory manager. * [mono][interp] Stop leaking data items Previously we were registering imethod locations from these data items in order for them to be patched once a method is tiered up. Because of this registering, the data item had to always be around. We now free the data item for dynamic methods and also we deregister the patch locations when freeing such a method. * [mono][interp] Free headers allocated for inlined methods We add them to a list for later freeing. This uses the same pattern as jit. * [mono][interp] Skip interp free for methods not yet compiled
…otnet#119176) * [mono][interp] Fix leaking of compilation data For dynamic methods, imethod_alloc0 allocates from the dynamic method's mempool which is freed when the method is collected. We were previously allocating only from the global memory manager. * [mono][interp] Stop leaking data items Previously we were registering imethod locations from these data items in order for them to be patched once a method is tiered up. Because of this registering, the data item had to always be around. We now free the data item for dynamic methods and also we deregister the patch locations when freeing such a method. * [mono][interp] Free headers allocated for inlined methods We add them to a list for later freeing. This uses the same pattern as jit. * [mono][interp] Skip interp free for methods not yet compiled Fix attempt to free tiering data when tiering is disabled (dotnet#119294)
…otnet#119176) * [mono][interp] Fix leaking of compilation data For dynamic methods, imethod_alloc0 allocates from the dynamic method's mempool which is freed when the method is collected. We were previously allocating only from the global memory manager. * [mono][interp] Stop leaking data items Previously we were registering imethod locations from these data items in order for them to be patched once a method is tiered up. Because of this registering, the data item had to always be around. We now free the data item for dynamic methods and also we deregister the patch locations when freeing such a method. * [mono][interp] Free headers allocated for inlined methods We add them to a list for later freeing. This uses the same pattern as jit. * [mono][interp] Skip interp free for methods not yet compiled Fix attempt to free tiering data when tiering is disabled (dotnet#119294)
Free method headers created for inlining. Make some offsets arrays used by dynamic interp methods freeable. Make tiering data and the data items for dynamic methods freeable.