简体   繁体   English

F#交互式GC堆转储

[英]F# interactive GC heap dump

I was investigating an F# script running via FsiAnyCpu which was using a lot of memory. 我正在研究通过FsiAnyCpu运行的F#脚本,该脚本占用了大量内存。 I took a heap snapshot using PerfView and it looks like the majority of high count nodes were rooted in FSharp.Compiler!Microsoft.FSharp.Compiler.Ilxgen+IlxAssemblyGenerator . 我使用PerfView拍摄了一个堆快照,看起来大多数高计数节点都植根于FSharp.Compiler!Microsoft.FSharp.Compiler.Ilxgen+IlxAssemblyGenerator Before taking the snapshot, I forced a GC and froze the process for the duration. 在拍摄快照之前,我强行执行了GC并冻结了整个过程。

The default exclusive view shows: 默认的独占视图显示:

在此处输入图片说明

Is this to be expected? 这是可以预期的吗?

FSI generates assemblies to contain code that you evaluate. FSI生成程序集以包含您评估的代码。 That code can hold rooted references to heap objects. 该代码可以保存对堆对象的根引用。 Expressions that you evaluate can cause rooted references as well. 您评估的表达式也可能导致植根引用。 FSI is likely to behave as a by-design memory leak--if a REPL didn't remember what you'd previously evaluated it might not be so useful. FSI可能是由于设计原因而导致的内存泄漏-如果REPL不记得您之前评估过的内容,那么它可能没有用。 It can also hold open references to files and assemblies, for the same reasons. 出于相同的原因,它也可以保存对文件和程序集的开放引用。

Within Visual Studio FSI provides a context menu command called "Reset Interactive Session" which cleans everything up. 在Visual Studio中,FSI提供了一个上下文菜单命令,称为“重置交互式会话”,它可以清理所有内容。 For the command line FSI presumably you can just terminate it. 对于命令行FSI,大概可以终止它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM