C ++“delete”是慢的。我应该在哪里看第一? [英] C++ "delete" is slow. Where should I look first?

查看:143
本文介绍了C ++“delete”是慢的。我应该在哪里看第一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++应用程序,其中删除功能运行缓慢。

I have a C++ application where the "delete" function is slow to run. What might cause this and where should I begin my search for a solution?

背景

此C ++代码位于AutoCAD内部运行的ARX文件中,基本上只是一个DLL。

This C++ code is in an ARX file running inside of AutoCAD, which is basically just a DLL.

删除速度慢的特定计算机正在运行AutoCAD 2011 ,Windows 7,64位。 AutoCAD 2011的ARX必须使用Visual Studio 2008 Service Pack 1进行编译。

The specific computer where delete is slow is running AutoCAD 2011, Windows 7, 64-bit. ARX's for AutoCAD 2011 have to be compiled using Visual Studio 2008 Service Pack 1.

问题的计算机是客户的计算机。它没有安装任何版本的Visual Studio。

The computer with the problem is a customer's computer. It does not have any version of Visual Studio installed on it.

在我的开发计算机上,该代码在AutoCAD 2011中没有任何问题。

On my development computer, the code does not have any problem in AutoCAD 2011.

要测试,我有一些代码,删除链表。在有问题的计算机上,删除列表需要0.7秒。在没有问题的计算机和配置上,相同的代码需要0.02秒。具体的时间不重要 - 两个数字之间的巨大差异是

To test, I have some code that deletes a linked list. On the computer with the problem, it takes 0.7 seconds to delete the list. On the computers and configurations without the problem, the same code takes 0.02 seconds. The specific times are not important--the large different between the two numbers is.

我确保在两台计算机上运行相同版本的代码,所以它不是发布与调试生成问题。

I made sure to be running the same version of the code on both computers, so it is not a release versus debug build problem.

推荐答案

大致按照我会检查它们的顺序:

Roughly in the order I'd check them:


  • 其他插件可能会导致其他ARX文件造成的行为吗?他们可以在坏的系统上禁用?

  • PerfMon:在删除期间检查软/硬页错误或缓存未命中峰值(我希望您可以在客户计算机上设置) > 线程在后台高度活跃,紧紧抓住堆的锁?你可以通过在HeapLock / HeapUnlock中包装循环来测试(当然还有锁内的时间)。

  • Hooks: (例如,第三方应用程序挂钩到C ++ / Win32堆函数中以做任何想做的事情)

  • 吸管: $ c> new 的时间过长?如何分配个人删除的时间?

  • Other plugins: could that behavior caused by other ARX files? Can they be disabled on bad system?
  • PerfMon: Check if soft/hard page faults or cache misses peak during your delete (I hope you can set that up on the customers computer).
  • HeapQueryInformation: same values in good/bad environment?
  • Heap Lock: Could some other thread be highly active in the background, holding tight to the heap's lock? You could test by wrapping the loop in HeapLock / HeapUnlock (and time inside the lock, of course).
  • Hooks: Could the respective code be hooked? (e.g. a 3rd party app hooking into the C++/Win32 Heap functions to do whatever it wants to do)
  • Grasping at straws: Do the respective new's take unusually long? How are the individual delete times distributed?

这篇关于C ++“delete”是慢的。我应该在哪里看第一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆