Why in cpp a dll in debug mode is X10 bigger than release while in .Net they are almost the same size?
Maybe because in .Net, it's the runtime engine which handle all debug checks, whereas in CPP, all the checks are compiled into the DLL.
To Debug a C++ program alot of extra information has to be kept in the DLL so the debugger can find out about the code at run-time. C++ has no run-time requirement to be able to inspect the code unlike C# which allows for extensive run-time inspection also known as reflection. This information is there in C# whether using debug or release mode.
Additionally C++ is usually compiled directly to machine code in release mode the objective of the compiler is to optimized the code as much as possible, eg. remove any and all extraneous information and code. In C# the compiler compiles to a pseudo code which is just in time compiled as required. This code keeps much of what is required for debugging regardless if it is release or debug that you are building. So much so that it is possible to write a de-compiler to give you the code back from a run-time assembly.
.Net DLLs contain metadata which support runtime reflection, type safety and code access security. The only things that are in the PDBs is local variable names and line numbers.
Where as in C++ additional metadata and sometimes no-ops need to be injected to support debugging.
You mean C# not .NET. Also it depends on your project.
I have one C++/CLI DLL which is 54K in release and 94K in debug,
and another which is 88KB in release and 124KB in debug.
My C++/CLI EXE which includes MFC is 471KB in release and 4446KB in debug!
And then my C# DLL is 135KB in both debug and release.