Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slow performance on x64 free

I have a class like this (assume all malloc's succeedes)

class CMyClass
{
public:
  CMyClass()
  {
  lpData = malloc(128);
  };

  ~CMyClass()
  {
  free(lpData);
  };

public:
  LPVOID lpData;
};

then I execute this:

CMyClass *lpList = new CMyClass[32768];

delete [] lpList;

The problem is that in x86 the code works fine and fast (some milliseconds to complete in debug and release builds) but in x64 the delete call takes about 15 seconds to free all memory.

O.S. is Win7 x64.

Hints will be appreciated.

Regards, Mauro.

like image 352
Mauro H. Leggieri Avatar asked Jul 01 '11 18:07

Mauro H. Leggieri


People also ask

How to speed up a slow PC?

In the search box on the taskbar, type performance, then select Adjust the appearance and performance of Windows in the list of results. On the Visual Effects tab, select Adjust for best performance > Apply. Restart your PC and see if that speeds up your PC. If your PC still runs slowly, continue to the next tip. 7. Pause OneDrive syncing

How to improve performance on Windows 10 PC?

Tips to improve PC performance in Windows 10. 1 1. Make sure you have the latest updates for Windows and device drivers. 2 2. Restart your PC and open only the apps you need. 3 3. Use ReadyBoost to help improve performance. 4 4. Make sure the system is managing the page file size. 5 5. Check for low disk space and free up space. More items

Why is my computer running slow on Windows 9?

9. Check for and remove viruses and malware A virus, malware, or malicious software could cause your PC to run slowly. Other symptoms include unexpected pop-up messages, programs that unexpectedly start automatically, or the sound of your hard disk constantly working.

What should I do if my PC performance is low?

Here are the tips in order of what you should try to fix the problem. To get more information about each tip, use the Tips to improve PC performance link at the bottom of this topic. Check your updates for the latest updates for Windows and device drivers. Restart your PC with only apps you need.


2 Answers

It is possible that if you are running your test app through a debugger that you are hitting some performance issue with the Windows debug heap. Add _NO_DEBUG_HEAP=1 to the environment settings for the debuggee (in the Project Properties->Configuration Properties->Debugging->Environment property under Visual Studio 20xx) and see if that improves your deallocation perf.

like image 179
MSN Avatar answered Oct 06 '22 11:10

MSN


I just tested this myself, using gcc 4.6.1-1 on Debian (after adding typedef void *LPVOID). There is no difference; both execute instantly, even without any optimization turned on.

I upped the array length to 1048576 to get a measurable runtime (0.161s), which was the same for both IA32 and AMD64. I turned on optimizations (-O3), and the time remained the same, but decreased to 0.157s. -Os (optimize for size) had the same result.

Is it possible you used different build options, like maybe you have some sort of memory access debugging enabled on AMD64?

like image 1
derobert Avatar answered Oct 06 '22 12:10

derobert