i create a mutex to prevent more than one instance of my program to run. the program works fine. the problem is that once i have the program running and i try to startup another instance memory is used up but not freed up after the process exits. as i watch the task managers memory it increase everytime i startup the program. why is this shouldnt my memory free itself? the only thing it does is to continueously increase.
Posted on 2002-01-17 17:31:21 by smurf
Well, PlatformSDK has the following to say:


Use the CloseHandle function to close the handle. The system closes the handle automatically when the process terminates. The mutex object is destroyed when its last handle has been closed.

So the mutex ought to be destroyed when your app termiantes,
even if you don't CloseHandle it. Perhaps the memory "leak" is just
because windows has cached some stuff? Also, remember that a
lot is going on inside windows... even when not much is going on,
you should see the memory usage go up and down a bit.

Try making a little application that runs your test app, say, 200
times (or perhaps even more), and see if the leaking is severe.
If it is, make the launch app launch the other app indefinitely, and
see if you eventually exhaust the system resources or get some
interesting error messages. If you're on an NT based windows, it
might be a good idea to use the sync.exe utility from www.sysinternals.com ,
just to be safe.
Posted on 2002-01-17 20:17:01 by f0dder
hey f0dder i executed my app more than a few hundred times sequentially and had little effect on my computer. this is mainly becuase my app isnt really doing much .. but the memory still goes up about 12kbs every times the app is executed. its not much damage really but i was just wondering what was going on since the memory wasnt coming back down.
Posted on 2002-01-17 21:04:47 by smurf
I made the following batch file and let it run for a few minutes on
my wink box:



@echo off
:badbad
start test.exe
goto badbad


Memory usage went up and down and up and down and (...) just
as it's supposed to. Couldn't see any leaks at all.
Posted on 2002-01-18 05:10:03 by f0dder