What's the memory footprint of the DLR?

百般思念 提交于 2020-01-03 15:20:10

问题


I'm considering making limited use of C#'s dynamic keyword. My initial time trials were astonishing - a performance hit of less than a second for 100,000 iterations (likely due to DLR caching).

I don't have access to a memory profiler, though, and Eric Lippert wrote:

Then it starts up the DLR [...] The DLR then starts up a special version of the C# compiler...

What's the memory footprint of this, and is it unloaded when the dynamic code is garbage-collected?


回答1:


is it unloaded when the dynamic code is garbage-collected?

The question presupposes an incorrect premise; the dynamically generated code isn't garbage collected in the current implementation. It is cached and the caches live until the appdomain is torn down. We don't know when the last time a particular code path is going to be called.

If you want to know the impact on virtual memory, heap memory, private bytes, shared bytes, and so on, then my suggestion is that you use a memory profiler to answer those specific questions. There are a half a dozen different "memory footprints" you could be interested in, and I don't know which one is relevant to you. Use the appropriate tool to measure whatever is interesting to you, and then you'll know.



来源:https://stackoverflow.com/questions/5212064/whats-the-memory-footprint-of-the-dlr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!