-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix memory leak in Program::ReadFromFile() #36857
Comments
See also #33973 which tracks the fact that we don't want to keep the memory alive until isolate shutdown but rather want to keep it alive until it's not needed anymore. |
The lifecycle of the kernel_data is complicated. It's passed to the Program, but then other things take references to the kernel_data (or views into the middle of it) that outlive the Program. It's a bit of a mess. Hopefully there's a single object somewhere (maybe the Library?) that has the same lifespan as the kernel_data that can conditionally take ownership of it (but only if it was constructed by an isolate_reload). |
…r kernel buffers" This reverts commit ab6aeaa. Revert "[vm/compiler] Speed up the compiler part which deals with kernel reading up in DEBUG mode" This reverts commit b316210. Reason for revert: regression of snapshot sizes (DNO-599). Original change's description: > [vm/kernel] Use GC-tracked ExternalTypedData/TypedDataView for kernel buffers > > Until now we often leaked kernel buffers (e.g. hot reload buffers) because various > objects were referencing ExternalTypedData objects pointing into the middle of > c-allocated memory. This made it impossible for the GC to determine when the last > reference is gone. > > This CL ensures that the actual buffers are *always* made available via > ExternalTypedData and any inner pointers into it are created via TypedDataViews. > > The embedder guarantees to the free kernel buffers it has provided to: > - Dart_CreateIsolateFromKernel > - Dart_LoadScriptFromKernel > - Dart_LoadLibraryFromKernel > - Dart_SetDartLibrarySourcesKernel > on isolate shutdown. > > All other kernel buffers will get a finalizer attached, which ensures the > kernel buffers get freed by the GC once they are no longer referenced: > - Kernel blobs for expression evaluation > - Kernel blobs for Hot-Reload > - Kernel blobs for cc tests > > Fixes #33973 > Fixes #36857 > Issue #37030 > > Change-Id: I1cc410c94c0f4b229413e793728a261afcb10aaf > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103130 > Reviewed-by: Ryan Macnak <rmacnak@google.com> > Commit-Queue: Martin Kustermann <kustermann@google.com> TBR=kustermann@google.com,rmacnak@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I49715d2400f4a5c8806b7d6a2912b7258f671a0a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104343 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Auto-Submit: Alexander Markov <alexmarkov@google.com>
The code in runtime/vm/kernel_binary.cc:
Seems to never get freed.
The usage of this buffer is in runtime/vm/isolate_reload.cc.
Notice that in the
else
branch we do attach a finalizer to an artificially createdExternalTypedData
to ensure it's freed (at isolate shutdown time - we keep it around longer than necessary).But if the hot-reload blob is loaded from the file, we don't do this.
The text was updated successfully, but these errors were encountered: