Silly Question On Windows Memory Allocation Again

Started by
2 comments, last by Rattenhirn 19 years, 4 months ago
I've been debugging what I thought was a memory leak. My application starts out at X value for memory usage (based on CTRL-Alt Del in WIN to look at the processes). When I look at it again, it is Y value. My app is interactive and executes different sections of code depending on the situation. For instance, let's say it needs to perform a specific task, the memory usage goes up. Yet, if it performs the same task again, the memory does not go up. Hence, if differnt tasks are never performed the memory does not go. The memory is different at different points in time based on the tasks performed. Would this be a correct anaylsis of the situation? If true, why is this so in WIN. If I declare some int's in a function (not dynamically mind you, just "int x = 4;"), shouldn't WIN reclaim the memory after I exit the function. I'm sorry to ask the question again. Thanks.
Advertisement
The stack grows automatically and is never shrunk.
Calling different routines may cause their code to paged into RAM from disk. This memory is paged back out to disk when the OS decides that it hasn't been used for "a while".
Read up on virtual memory.
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
That the worst way to see if your application leaks memory. Either use crt memory debug functions or something like fluid studios memory manager.
Windows task manager gives very unreliable numbers on memory use.

If you don't use any new's and alloc/malloc's you can't have a memory leak.

The most lowtech way to find out if you have a memory leak in your application is to have it running for a very long time (hours & days) and do stuff with it. If the memory use reported by the task manager reports a very high value, than you very likely have a memory leak. the smaller the mem leak, the longer it takes to see any effect.

There are several tools out there to check for memory leaks in your application, altough there's none I can.

Hope that helps...

[Edited by - Rattenhirn on December 6, 2004 3:47:55 AM]

This topic is closed to new replies.

Advertisement