【发布时间】:2013-03-28 03:14:58
【问题描述】:
谁能告诉我为什么会发生以下事情:
我有两台电脑:
- 我的工作组合
- 服务器
我维护的 C++ 程序(msvc 2005 c++ 编译)只在服务器上运行太慢, 但不在我的比赛中。
我进行了测量(GetThreadTimes 等) 并且可以肯定地说狭窄的地方 - 它的内存分配 (新/malloc)。而且它只发生在服务器上!
我可以声称这是由于内存碎片造成的 程序的第一次服务器实例工作正常,它开始失去时间 仅在数据重新加载到内存(1-150 万次分配/释放)后才在分配上。
如果我因记忆而看到相同的行为,我不会那么惊讶 两台计算机上的碎片(我的计算机和服务器) 但我看到的是: 1)。在我的补偿分配上花费约 5% 的时间(不准确,但类似) 2)。在服务器上,这些分配需要大约 75% 的时间
这怎么可能发生?什么会减慢服务器计算机上的 C++ 分配, 同时它适用于我的工作站。哪里可能有区别? 可能它与操作系统级内存管理功能有关? 因为 C++ 级别管理器在这两种情况下都是一样的。
这是两种配置:
1)。我的电脑(allocs 占 ~5%):
OS Name: Microsoft Windows 7 Enterprise
OS Version: 6.1.7600 N/A Build 7600
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free
Registered Owner: Windows User
Original Install Date: 16/09/2011, 19:37:43
System Boot Time: 05/04/2013, 11:58:11
System Model: 7304A58
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 23 Stepping 10 GenuineIntel ~2642 Mhz
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume2
System Locale: ru;Russian
Input Locale: en-us;English (United States)
Total Physical Memory: 4,061 MB
Available Physical Memory: 872 MB
Virtual Memory: Max Size: 8,121 MB
Virtual Memory: Available: 4,579 MB
Virtual Memory: In Use: 3,542 MB
Page File Location(s): C:\pagefile.sys
2)。服务器(allocs 占 ~75%):
OS Name: Microsoft(R) Windows(R) Server 2003, Enterprise Edition
OS Version: 5.2.3790 Service Pack 2 Build 3790
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Server
OS Build Type: Multiprocessor Free
Original Install Date: 11/12/2008, 01:22:57
System Up Time: 1 Days, 8 Hours, 35 Minutes, 52 Seconds
System Manufacturer: HP
System Model: ProLiant BL685c G5
System Type: X86-based PC
Processor(s): 4 Processor(s) Installed.
[01]: x86 Family 16 Model 2 Stepping 3 AuthenticAMD ~2210 Mhz
[02]: x86 Family 16 Model 2 Stepping 3 AuthenticAMD ~2210 Mhz
[03]: x86 Family 16 Model 2 Stepping 3 AuthenticAMD ~2210 Mhz
[04]: x86 Family 16 Model 2 Stepping 3 AuthenticAMD ~2210 Mhz
Windows Directory: C:\WINNT
System Directory: C:\WINNT\system32
Boot Device: \Device\HarddiskVolume1
Total Physical Memory: 65,534 MB
Available Physical Memory: 61,284 MB
Page File: Max Size: 97,696 MB
Page File: Available: 93,445 MB
Page File: In Use: 4,251 MB
Page File Location(s): C:\pagefile.sys
D:\pagefile1\pagefile.sys
D:\pagefile2\pagefile.sys
D:\pagefile3\pagefile.sys
D:\pagefile4\pagefile.sys
D:\pagefile5\pagefile.sys
D:\pagefile6\pagefile.sys
D:\pagefile7\pagefile.sys
非常感谢您澄清这个问题。
【问题讨论】:
-
你在两台机器上使用相同的数据集吗?
-
不,但可以比较。我的 comp 有大约 260 000 个项目流畅地工作,服务器 comp 在大约 350 000 个时遇到困难,甚至在加载第 100 000 个项目时它甚至开始努力工作。
标签: c++ memory allocation memory-fragmentation