tags:

views:

174

answers:

1

Hi to all,

I have just used FastMM4 to detect leaks. I did not realise our application was using a DLL which was leaking event handles and so I fixed any leaks reported by FastMM4 but not the handles as it was not reported.

My questions are, would have FastMM4 have reported the leaking event handles? Would this require me to rebuild the dlls with FastMM4 included? I also heard someone mention ShareMM, do I need to add that?

I am using Delphi2007, which I think is using the borland memory manager and if so, should I replace it with the fastMM4 one? What are the steps to do that?

Sorry for asking so many questions, I am looking at delphi after a few years of doing .net development.

JD.

+8  A: 

No. FastMM is a memory manager, and it can only report leaks of memory that the application allocated via FastMM. Handles are opaque references to system objects that are allocated by Windows, so FastMM can't track them, and neither can any other Delphi memory manager.

And this isn't really a Delphi vs. .NET thing either, since .NET's garbage collection couldn't have solved this problem any better than FastMM can. Handles are non-memory resources and you have to keep them from leaking the same way you would in .NET: make sure that anything that allocates one releases it when you're done with it.

Do you know what type of handle you're leaking? If it's something less common than the ubiquitous HWND, that would be a good starting point in tracking down the problem: find where you're allocating that type of handle.

As for your other question, about Delphi 2007, it comes with FastMM built in, not the old BorlandMM. But it's sort of a basic version. For access to the FullDebugMode functionality, you need to download FastMM from SourceForge and add it at the top of your uses list and rebuild with the FullDebugMode compiler define on.

Mason Wheeler
Thank you Mason. We tried Windbg and found that handles of type Event were leaking. I managed to fix that as it was in the DLL and now they have stopped leaking. I heard that in general we should use FastMM4.dll for better memory management, for applications out in the field, should I just replace fastmm.dll with fastmm4.dll or do I need to recompile my code with references to fastmm4.pas etc?
JD
I didn't know there was a fastmm dll. FullDebugMode uses a dll for the advanced analysis, but the memory manager itself is just a couple pas files and an include file, and the basic functionality is built in to Delphi 2007. Just recompile under D2007 and your DLL will be FastMM enabled unless it explicitly uses a replacement memory manager.
Mason Wheeler
Sorry, my bad. Okay, thanks for the information.
JD