如何找出为什么我的 DLL 增长如此之多
我一直在开发的一个 DLL 最近变得越来越大。有没有任何工具可以告诉我造成这种情况的原因是什么?例如,它是否是一个被实例化太多次的模板,或者可能是第 3 方库,或者可能是 boost?
我正在寻找一种关注尺寸而不是性能的分析器。
A DLL I've been working on has recently grown a lot in size. Are there any tools that will tell my what is responsible for this? For instance, is it a template that is being instantiated too many times, or perhaps a 3rd party lib, or maybe boost?
I'm looking for a kind of profiler that looks at size rather than performance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你说的是 DLL 的大小(以字节为单位)吗?尝试使用 dumpbin 实用程序。这可以向您显示 DLL 内部的内容。 /ARCHIVEMEMBERS 应该向您显示各个对象模块。
http://support.microsoft.com/kb/177429
Are you talking about size of the DLL in bytes? Try using the dumpbin utility. This can show you what's inside your DLL. /ARCHIVEMEMBERS should show you the individual object modules.
http://support.microsoft.com/kb/177429
如果您的 DLL 有其他依赖项,并且您使用静态链接将 DLL 链接到它们,则您的 DLL 可能会变得更大:
静态链接与动态链接
编辑:
我发现这个线程中的答案对于您的问题非常有趣:分析 DLL/LIB 膨胀
但一个有趣的实验是验证对于每个模板实例化,生成的可执行文件大小是否线性增长。如果是这样,您就知道您的问题是模板实例化。这里有一篇不错的文章< /a> 讨论了此类问题并提出了一种重构它的技术。
编辑:
您的问题很可能是使用 boost 标头的结果。检查此线程以找出原因:为什么使用 boost 会增加文件大小这么多?
If your DLL has other dependencies and you are using STATIC linking to link your DLL to them, you can expect your DLL to grow larger:
Static linking vs dynamic linking
EDIT:
I found the answers in this thread quite interesting for your problem: Profiling DLL/LIB Bloat
But an interesting experiment would be to verify if for each template instantiation, the resulting executable size grows linearly. If it does, you know your problem is template instantiation. There's a decent article here that talks about this type of problem and presents a technique to refactor it.
EDIT:
There's a big chance that your problem is a consequence of using boost headers. Check this thread to find out why: Why does using boost increase file size so much?