Sign in to follow this  
fathom88

Silly Question On Windows Memory Allocation Again

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this