I have a rather large project in C / C ++, and I'm trying to find out why it consumes an excessive amount of memory (judging by the "Working Set" in the task manager). I finally tracked it down to weird behavior that even for the smallest malloc () requests will highlight a full new 4k page. Code like this
for(int bla = 0; bla < 1000; bla++)
{
char* blu = (char*)malloc(10);
}
which should increase memory consumption by 10 KB, ends with 4 MB, since it makes 1000 4 KB of allocations.
The really disappointing part is that I cannot reproduce it as autonomous. A small application, only with the code above, works great. Only a large project exhibits abnormal behavior. To answer some obvious suggestions directly:
I deal with the same libraries as a large project, and I'm also sure that the compilation flags are the same
"new" behaves the same
This happens both in debug mode and in Release mode.
I really tracked it down to calling HeapAlloc, which is the culprit. Unfortunately, you should not join HeapAlloc for further study.
Any ideas? I am completely at a dead end.
source
share