Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the memory footprint of the DLR?

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?

like image 559
TrueWill Avatar asked Mar 06 '11 17:03

TrueWill


1 Answers

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.

like image 72
Eric Lippert Avatar answered Oct 20 '22 00:10

Eric Lippert