调试与发布 dll 大小

发布于 2024-08-09 08:20:42 字数 59 浏览 9 评论 0原文

为什么在 cpp 中,调试模式下的 dll 比发布模式下大 X10,而在 .Net 中它们几乎相同大小?

Why in cpp a dll in debug mode is X10 bigger than release while in .Net they are almost the same size?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

北渚 2024-08-16 08:20:42

要调试 C++ 程序,必须在 DLL 中保存大量额外信息,以便调试器可以在运行时找到代码。与 C# 不同,C++ 没有运行时要求能够检查代码,C# 允许广泛的运行时检查(也称为反射)。无论使用调试模式还是发布模式,C# 中都存在此信息。

此外,C++ 通常在发布模式下直接编译为机器代码,编译器的目标是尽可能优化代码,例如。删除任何和所有无关的信息和代码。在 C# 中,编译器编译为伪代码,该伪代码根据需要及时编译。该代码保留了调试所需的大部分内容,无论您正在构建的是发布还是调试。如此之多以至于可以编写一个反编译器来从运行时程序集中返回代码。

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.

热风软妹 2024-08-16 08:20:42

也许是因为在.Net中,是运行时引擎处理所有调试检查,而在CPP中,所有检查都编译到DLL中。

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.

时光礼记 2024-08-16 08:20:42

.Net DLL 包含支持运行时反射、类型安全和代码访问安全的元数据。 PDB 中唯一的内容是局部变量名称和行号。

与 C++ 一样,需要注入额外的元数据,有时需要注入空操作来支持调试。

.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.

盗琴音 2024-08-16 08:20:42

你指的是 C# 而不是 .NET。这也取决于您的项目。

我有一个 C++/CLI DLL,发布版为 54K,调试版为 94K,
另一个版本是 88KB,调试版本是 124KB。

我的包含 MFC 的 C++/CLI EXE 在发布时为 471KB,在调试时为 4446KB!

然后我的 C# DLL 在调试和发布时都是 135KB。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文