Hello,
I have a program which call only one time malloc at the start of the program. When running, I see with 'process-explorer.exe' that memory is growing in little steps. Is this normal? why?
Thanks in advance
FS
P.S.: using Windows 7
Hello,
I have a program which call only one time malloc at the start of the program. When running, I see with 'process-explorer.exe' that memory is growing in little steps. Is this normal? why?
Thanks in advance
FS
P.S.: using Windows 7
It's hard to tell without seeing the source code. Normally if you have one malloc call then you should also have a corresponding free call. If you are doing it in a loop, then obviously malloc calls will increase the amount of allocated memory over time.
It is called only one time and free at the end of the program. No loop.
The only datail that maybe is of importance is that I malloc a big chunk of memory (128 MB). I could do it without malloc, inside the code with a big array, but it is a parameter that I let choose to the user, so that is the reason I use malloc.
This essue is very strange to me.
CyberNotes: Windows Memory Usage Explained
Care to clarify what you mean by "memory increasing"?
Windows gives you at least half a dozen "memory stats" to ponder over, so you need to get informed as to what they all mean (not to mention the variety of different names for the same thing).
The VM allocated to the process would have risen at the point of the malloc call, but it would not have immediately been mapped into physical memory.
This would only happen when your code touched each page in the allocated block. So as you work your way through memory, the working set size might increase (up to some point), when old pages start to get swapped out to the swap file.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Without seeing any source code, it's hard to see how a definitive answer can be given. Make a minimal test case that shows this issue, and someone can give a better answer.
It depends entirely on what memory stat you are looking at. You should be looking at "Private Bytes".
If that continually increases then one way or another, your program IS requesting more and more memory. malloc is just one of the many ways your program can acquire more memory / resources. Any API call for which a corresponding release type of method is provided is another.
E.g. If you call FindFirstFile, then you must call FindClose.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"