4

In .NET 4.5 we have setup our assemblies to build debug symbols for the Release build - to aid debugging crash dumps etc... on customer sites.

My question is: without a debugger attached and running normally in production does the presence of debug symbols cause the garbage collector to behave differently?

I recently read the following in an ebook:

"each of these assemblies will be compiled with debug symbols, resulting in poorer performance, and meaning that the GC will not work as effectively as in a release build. Essentially, the GC will be less aggressive in reclaiming memory when debug symbols are included. Since the debug symbols are included, the GC needs to be prepared that a debugger could be attached, and many of the rules for identifying unreachable references may not be applicable. With a debugger attached, a lot more objects may be reachable."

Is this true?

solidstore
  • 105
  • 1
  • 14

1 Answers1

1

What you are reading applies to code compiled in debug mode, or to some extent, code running with a debugger attached. Having debug symbols is just a side effect of compiling in debug mode, the debug symbols themselves doesn't change the behaviour.

The garbage collector extends the lifetime of variables in the debug mode from variable usage to variable scope. This is based on the presence of a debugger, not on the presence of debug symbols.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • thanks. I'll continue to distribute the symbols along with the release code. I was just worried it affected GC performance even without a debugger attached. – solidstore Jul 02 '13 at 16:28
  • @Gufffa Do you have any official source for this information? – Jim Aho Dec 04 '14 at 14:56
  • 1
    @JimAho: Well, it's a combination of official and other sources... official sources often leave you without a clear conclusion, and other sources are often not completely correct. A pair of examples of good sources: [Does garbage collection run during debug?](http://stackoverflow.com/questions/7165353/does-garbage-collection-run-during-debug), [On Garbage Collection, Scope and Object Lifetimes](http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2005/02/17/5272.aspx). – Guffa Dec 04 '14 at 16:22