15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Tracking memory leaks with _afxBreakAlloc

Marty Wagner -- marty@concentra.com
Wednesday, February 07, 1996




How do you track down memory leaks with _afxBreakAlloc??

I found the VC++ knowledge base article Q122307 in the January 96
MSDN.  It explains a great way to break on a particular memory
leak. It would be very useful for the memory leaks that we have, where
we know the file that they are appearing in but we can't figure out
why they are leaking.

However, the article's instructions don't work as advertised.  The
article says to set a breakpoint in the function AfxAllocMemoryDebug
in the file AFXMEM.CPP. I did that, but the breakpoint was never
reached. When I looked at the MFC browse file, I found that
AfxAllocMemoryDebug is, in fact, never called.

Has anyone used this technique successfully in VC++ 4.0?  Please let me know 
if you have!!! 

-- 

Marty Wagner
Concentra Corporation
21 North Avenue
Burlington MA 01803-3301
(617) 229-4640

marty@concentra.com

----------------------------------------------------------
|  "Does the chicken need a reason?"                     |
----------------------------------------------------------






Mike Blaszczak -- mikeblas@interserv.com
Thursday, February 08, 1996

[Mini-digest: 4 responses]

On Wed, 7 Feb 1996, Marty Wagner  wrote:

>How do you track down memory leaks with _afxBreakAlloc??

At a cursory glance, that sounds like a bug in MFC. Maybe I can go into work 
and improve the load time of MFC42.DLL by one tenth of one thousandth of one 
percent by removing it.

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");

-----From: "Mukesh Prasad [Development Contractor]" 

AfxAllocMemoryDebug was used for debug allocations
until 2.1.  But looks like they have made changes in
4.0 to allow memory debugging for "malloc"s as well,
in addition to what they had, which only worked
for "new"s.

If you know the "request number" for your memory leak,
you should be able to use "AfxSetAllocStop( request_number )"
to set the stop.

-----From: Mike Martonfi 

Try CrtSetBreakAlloc(), instead.

-----From: MARGHAL@gw2k.com

_afxBreakAlloc is not supported in VC++ 4.0. (I believe it was removed as 
part of the memory allocation overhaul in MFC 4.0) Use _crtBreakAlloc 
instead.  See the Runtime Libary Reference article "Tracking Heap 
Allocations" for more information.

The documentation on _afxBreakAlloc that comes with VC++ 4.0 needs to have a 
pointer to the _crtBreakAlloc documentation. 

Al Margheim
x27108




| Вернуться в корень Архива |