Alex
2010-06-29 22:17:59 UTC
Memory allocation in our application is too slow, on average every new
malloc or 'new' is costing us about 3 to 4 milliseconds, which is a
huge hit to the performance, each 'new' is only allocating a few bytes
or 1Kbytes at most in our application. Our application allocates a
lot of memory at the begginning, but still it only uses about 3MB
memory, GlobalMemoryStatus shows there are still 16MB physical RAM and
about 29MB virtual RAM available. So how can allocating a few bytes
take 4ms?
ms.dwTotalPhys = 0x017ba000 24296KB 23MB
ms.dwAvailPhys = 0x010a2000 17032KB 16MB
ms.dwTotalVirtual = 0x02000000 32768KB 32MB
ms.dwAvailVirtual = 0x01dc0000 30464KB 29MB
I wrote another test application to reproduce and analyze the problem,
it allocates 10000 bytes each time and allocates 10MB at the
beginning, however subsequent malloc does not take that much time, it
only takes about 70 us for each malloc even after there is only 1MB
physical RAM available.
malloc or 'new' is costing us about 3 to 4 milliseconds, which is a
huge hit to the performance, each 'new' is only allocating a few bytes
or 1Kbytes at most in our application. Our application allocates a
lot of memory at the begginning, but still it only uses about 3MB
memory, GlobalMemoryStatus shows there are still 16MB physical RAM and
about 29MB virtual RAM available. So how can allocating a few bytes
take 4ms?
ms.dwTotalPhys = 0x017ba000 24296KB 23MB
ms.dwAvailPhys = 0x010a2000 17032KB 16MB
ms.dwTotalVirtual = 0x02000000 32768KB 32MB
ms.dwAvailVirtual = 0x01dc0000 30464KB 29MB
I wrote another test application to reproduce and analyze the problem,
it allocates 10000 bytes each time and allocates 10MB at the
beginning, however subsequent malloc does not take that much time, it
only takes about 70 us for each malloc even after there is only 1MB
physical RAM available.