Hey guys, do you know of any good programs(freeware preferable) that help you detect memory leaks?

When I run my ASM apps, I find the computer becoming more and more sluggish the more I run the apps. I can't really see anywhere in my code that could be killing my RAM but I don't know everything that the API I use reserves.

If there is a fairly intelligable program out there that can detect if I am forgetting to free any memory, and where it is located that would be cool.

Don't know if programs exist similar to Visual Studios Debugger that can tell you specifically that a DC resource was not freed, etc.


P.S. I do all my coding with RadASM, don't know if there are any known leaks associated with it?

btw - love that RadASM!!!!!!
Posted on 2002-01-06 16:33:55 by Rockinronstar
Heh, i have never heard of a freeware tool that does this. What i have used is DevPartner Studio from Numega, it has an add-in module that checks for memory leaks, and it is very good. It still works with my asm code as long as i do the asm coding in the VC editor, i have never tried to run it on a compiled app.

To track down memory leaks, check the following:
- are you creating fonts?
- are you creating pens or brushes?
- are you creating new dc's?
- are you allocating memory?
- are you obtaining handles to resources from a resource file?

with any of the above, the handles/resources/memory needs to be freed after you use it. Be aware there may be some scenarios that i have left out.
Posted on 2002-01-06 16:46:04 by sluggy
Hi Rockinronstar

On Win98 CreateProcess has a memory leak. RadASM uses this when assembling and linking. On Win2k and WinXP there are no memory leak as far as I know.

Posted on 2002-01-06 17:42:07 by KetilO
I am using WinXp, so RadASM is out. In my template APP I use for building my other Apps, I create a Single Overlapped Window and a menu.

Am I supposed to free the menu resource? I attach it in the class wc.MenuName, I thought things like this were freed when the App is terminated.

Maybe I should really check this out.

When you create a toolbar, Menu, Status Window, etc.

Are these resources freed when the App closes?
In the case of the menu, I would assume it is since you never grab a handle to the menu explicitly, but instead attach it to the window by name(when using the default menu from you WndClass).

I can see having to free it if you attach another menu in the CreateWindowEx function, but I am not sure abiut this?

I do Release all the DC's I use. Plsu handles to any other GDI objects.

what about the default brush you specify in your WndClass structure? Does this need to be freed, and if so how would you do since you never get a handle for it?

I would assume no for that one to, like the default menu.

If anyone knows about this resource freeing, your input would be appreciated.
Posted on 2002-01-06 17:58:00 by Rockinronstar
The stuff you supply in you wndclassex struct should not be eating the memory, as you only create your window once.

Are you using any dlls? There could be a memory leak in one of those. Alternatively, you are running XP, bring up the task manager and make sure it is your app that is eating the memory. And another possibility: XP has lots of .Net stuff built in, and the garbage collection only gets done when the system starts to run out of resources, you may have to look for a way to force a regular garbage collection (i think i have that theory fairly right :))
Posted on 2002-01-06 19:40:58 by sluggy
Actually i use winxp and the same problem happens, it's radasm. After i assemble & link about 30+ times the system slows down a lot. My only assumption would be that it's radasm.

Posted on 2002-01-06 21:25:40 by Asm_Freak

On Win98 CreateProcess has a memory leak. RadASM uses this when assembling and linking.

Also when you CloseHandle() on PROCESS_INFORMATION.hProcess
and PROCESS_INFORMATION.hThread ? I find it hard to believe there
would be a leak in such a vital and often called API. Even with 98
I've had "quite some hours" of uptime, and quite some CreateProcess
calls :).
Posted on 2002-01-06 21:49:04 by f0dder

Garbage collection only when it gets low on resources??

Who the heck thought of that one?

What a way to shoot yourself in the foot.

No, not using any Dll's

I think it could be my computer. It has been acting very weird for a few weeks now.

I get the occasional sudden restart and then into the bios for a message saying to Hit Reset Setting to finish installing my new CPU?? But I didn't install a CPU, haha. Maybe it was the cat?? lol

whew... Just spent 1 hour searching every web page in my serach engine on memory leak detection programs.
I only came across one that looked like it would work(not).

Doesn't seem to be much info, or resources concerning runtime memory leak detection.
Posted on 2002-01-06 21:54:50 by Rockinronstar
Lucky break. Instead of cluttering the board with a new topic, I'll add on to this one. When I ctrl+alt+del and look @ process, the app I'm creating takes up all the CPU time. I don't know why. It's just a simple window. I'm not using RadASM. I'm on Win2k.
Posted on 2002-01-06 21:56:59 by lackluster
Asm_freak, that is exactly what I get as well.

I'd say 20-30 times it gets extremely sluggish, and if I don't restart manually, then in about another 20-30 compile/run cycles I get restarted forcefully by XP's protection crap.

The strange thing is that I got 512 Megs of RAM , would take quite a memory leak to wear down that much Ram in 50-60 cycles????

I actually performed a test. I tried compiling with a batch file and no slow downs??

Just did some other tests.....

Opened up XP's task manager and looked at the mem usage of RadASM, when you move a window over any part of RadASM(except for the Rich Edit display(editor)) the mem Usage jumps up by quite a bit.

It keeps jumping and jumping. You don't have to recompile and run, just leave your window open on top of RadAsm and then slide it around/resize it, etc. you'll get the same slow downs

Also, I notice a jump in mem usage that keeps growing when you compile as well(think it was 4K jump each time)

Think RadASM is reserving alot of memory during run-time.

One thing though - When I close RadASm the system returns to normal. So the resources are freed eventually
Posted on 2002-01-06 22:16:01 by Rockinronstar

I have had the exact same thing happen to me at work on my Win2K machine.

It never happens on any MFC/VB/Delphi project.
Just on ones where I implement my own WinMain and WndProc and use all low-level API calls

I can only guess that the OnIdle isn't being handled, so the App appears to be handling "valid messages" all the time. But that is just a guess in the dark, I really have no clue why.

On my machine it says 99% of the CPU is being used by the App and the computer runs like crap(super sluggish)
Posted on 2002-01-06 22:21:19 by Rockinronstar
My computer has 12 applications running (two of which are RadASM) - 95+% idle. Both instances of RadASM are < 4meg memory usage. Running WinXP. Maybe it's a pluggin? It's been running all day - no problems.
Posted on 2002-01-06 22:31:21 by bitRAKE
Originally posted by Rockinronstar
On my machine it says 99% of the CPU is being used by the App and the computer runs like crap(super sluggish)

Exact same thing. Don't know why. Actually It happens in win32asm & C/C++. But I noticed it doesn't happen when I use dialogs. Like when I use .res files & link & load it doesn't happen. Only when I create the winmain. Weird.
Posted on 2002-01-06 22:36:53 by lackluster
I tried killing all the plug-ins and it still worked the same way.

What did work though was closing everything in RadASM.
I closed the toool window, the output window, and the two on the right.

I then compiled and ran about 20-30 times and didn't have a single slow down. Nor did the memusage increase.

I attached my RadASM ini file. Maybe there is something not configured correctly in there.

if you can take a look bitrake and match it against yours.

Posted on 2002-01-06 22:41:04 by Rockinronstar
looked pretty much the same as mine. I think I have 1 more plug-in enabled than you, but I was testing the slowdowns with all of the plug-ins removed.

are you using the latest version?

I downloaded the latest release 1.07 I believe
Posted on 2002-01-06 22:55:38 by Rockinronstar
guess we should really be directly these problems towards Ketilo.

Anyone know how to PM him with a link to this thread?
Posted on 2002-01-06 22:56:52 by Rockinronstar
Yeap, newest stuff running, but I am using ML/LINK.EXE version 7.0 from VS.Net.
Posted on 2002-01-06 22:57:59 by bitRAKE
version 7, wow. Is is stable?

Never thought MS would release anything over 6.15. I had a feeling they would try and kill the ASM market, haha

could you post a link where to get version 7 of ML and Link


also, back to the memory leaks. I turned off all of XP's pretty effects(Clear Type/ Shadows, fade effects) and made contents not shown while dragging and there was no memory leaks or slow downs with RadASM????

bitrake, you not using any of the settings I mentioned.

Wondering if you experienced no slow downs because you weren't using pretty effects
Posted on 2002-01-06 23:08:18 by Rockinronstar
I can only guess that the OnIdle isn't being handled, so the App appears to be handling "valid messages" all the time. But that is just a guess in the dark, I really have no clue why.

I just checked a couple of my (compiled) asm apps, and they use 0% cpu when they are running and i am not doing anything with them. Maybe you got something weird in your wndproc :)
Posted on 2002-01-07 00:24:03 by sluggy
Hi !
I've heard of a tool called Purify (Rational Software).
It's a complex and expensive tool (aimed at C++ programmers, mainly).
It has a very good reputation but I'm wondering if some of you know a good free memory leak detection software that is not like a Oil Plant. In fact, I'm speaking about something like OllyDBG for debuggers (something free, fast and relatively simple).

Posted on 2002-01-07 01:07:57 by JCP