|
i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak.
so, my problem is how to find the codes who eat up my memory.
any one can help me?
|
|
|
|
|
Apart from debugging, adding logging to your application or running some code analyzer[^] there is no answer.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Falconapollo wrote: so, my problem is how to find the codes who eat up my memory. Are you using the new operator?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
yes. but there is no memory leak in my codes as i wrote in my post.
|
|
|
|
|
Are you allocating memory to hold the "very large document?"
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
i'm not sure. since the codes are huge. i have no idea to find out the problematic codes.
so, what's your recommendations?
i think there are some existing tools to do that. do you know some?
|
|
|
|
|
First, when you do a malloc or new, you extend the heap. For optimization reasons, the memory manager may not return the heap back to the OS immediately. When needing to allocate especially large chunks of memory, you can use a low level API directly or, with some compilers/CRTs, a different heap (for Windows, here's an article discussion various options: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366533%28v=vs.85%29.aspx[^].)
Also note that if you allocate memory and sit around, the OS may page it out. To understand the difference in Windows, look into "private bytes" and "working set".
|
|
|
|
|
most of the time this problem is due to memory leak u check it again also check may be there is some large array defined in the code.like int arr[1024*1024][1024*1024].
|
|
|
|
|
application verifier is a good start.
|
|
|
|