You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internally, FlushPECaches tries to mark all readonly pages of PE images (this considers relocations too) as not needed so that they can be freed. This is done using madvise with MADV_DONTNEED.
This API marks all readonly PE Images pages as not needed so that they can be freed, reduces the size of the GC Heap and cleans up arena cache used for internal data during JIT compilation.
Internally, FlushPECaches tries to mark all readonly pages of PE images, this is done using madvise with MADV_DONTNEED (both dlls and ni.dlls are considered)
Flush jit calls JitHost::Reclaim()
Flush GC calls GC for max generation with compaction
For mapped files, I am not convinced that it makes sense to special case PE files. PE files are not that different from other (native) code in the process. Also, parts of the PE files and other code are immediately going to come back since they are referenced even in steady state. This should be implementable outside the runtime by walking all process memory and paging it out.
For Jit scratch space cache, this cache is not that big, and there number of similar caches in the core runtime (e.g. ArrayPool) or outside the code runtime in 3rd party libraries. Should all these caches participate somehow?
You mean not in net8 or not ever? Without understanding all the details, at least the intention seems to be a nice hack to bring the resource usage down, especially when the unloading using dlclose() is not supported..
Activity
jkotas commentedon Sep 18, 2019
I think this API should be about flushing all caches that the runtime controls: trimming unnecessary pages in GC heap, etc.
ashaurtaev commentedon May 14, 2024
Rationale and Usage
API that allows you to clear runtime caches on demand, which will reduce the overall memory consumption of the process.
We can later expand API and add other types of caches for flushing.
Usage
After this call Private_Clean and Shared_Clean of the process are reduced, as well as PSS and RSS.
or
After this call Private_Dirty of the process is reduced, as well as PSS and RSS.
Proposed API
Details
Pull Request
FlushPECaches part in dotnet/coreclr#26507 PR
@jkotas what do you think about this API?
cc @gbalykov @t-mustafin
jkotas commentedon May 14, 2024
For mapped files, I am not convinced that it makes sense to special case PE files. PE files are not that different from other (native) code in the process. Also, parts of the PE files and other code are immediately going to come back since they are referenced even in steady state. This should be implementable outside the runtime by walking all process memory and paging it out.
For Jit scratch space cache, this cache is not that big, and there number of similar caches in the core runtime (e.g. ArrayPool) or outside the code runtime in 3rd party libraries. Should all these caches participate somehow?
ashaurtaev commentedon May 20, 2024
Thanks for your feedback, let me think about it.
[-]API proposal: add function to flush PE caches[/-][+]API proposal: add function to flush caches[/+]anoop331 commentedon Jun 6, 2024
Will this api be introduced to net8, and if so, when would it be in place? Or is there a way to get a prelease version otherwise for us to try it out?
jkotas commentedon Jun 6, 2024
unlikely
anoop331 commentedon Jun 6, 2024
You mean not in net8 or not ever? Without understanding all the details, at least the intention seems to be a nice hack to bring the resource usage down, especially when the unloading using dlclose() is not supported..
jkotas commentedon Jun 6, 2024
The milestone is set to Future. It means that it may happen in some future dotnet version. It does not mean never.
ThaDaVos commentedon Oct 25, 2024
Any update on when this can be expected?