debugging memory leak in mfc

My debug build of program dumps the following in the trace when terminated:
 Detected memory leaks!
 Dumping objects ->
 {153} normal block at 0x00386AA8, 12 bytes long.
  Data: <hh8         > 68 68 38 00 00 00 00 00 06 00 00 00
 {152} normal block at 0x00386A68, 16 bytes long.
  Data: <                > 00 00 00 00 00 00 00 00 00 00 00

Where do I start looking for the memory leak? Is there any way to track the 
address to a corresponding object? 


0
pesso (6)
4/8/2006 3:13:39 AM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
848 Views

Similar Articles

[PageSpeed] 4

Try using this:
http://www.codeproject.com/tools/visualleakdetector.asp

U�ytkownik "Pesso" <pesso@no.where> napisa� w wiadomo�ci 
news:NuidndBQTJT_t6rZRVn-jw@comcast.com...
> My debug build of program dumps the following in the trace when 
> terminated:
> Detected memory leaks!
> Dumping objects ->
> {153} normal block at 0x00386AA8, 12 bytes long.
>  Data: <hh8         > 68 68 38 00 00 00 00 00 06 00 00 00
> {152} normal block at 0x00386A68, 16 bytes long.
>  Data: <                > 00 00 00 00 00 00 00 00 00 00 00
>
> Where do I start looking for the memory leak? Is there any way to track 
> the address to a corresponding object?
> 


0
feliks (8)
4/8/2006 7:57:24 AM
In article <NuidndBQTJT_t6rZRVn-jw@comcast.com>, pesso@no.where says...
> My debug build of program dumps the following in the trace when terminated:
>  Detected memory leaks!
>  Dumping objects ->
>  {153} normal block at 0x00386AA8, 12 bytes long.
>   Data: <hh8         > 68 68 38 00 00 00 00 00 06 00 00 00
>  {152} normal block at 0x00386A68, 16 bytes long.
>   Data: <                > 00 00 00 00 00 00 00 00 00 00 00
> 
> Where do I start looking for the memory leak? Is there any way to track the 
> address to a corresponding object? 

Doesn't clicking on the error message often take you to where the 
memory was allocated, or am I imagining things?

If not, at least you know how big the object is, which may be a clue.

- Gerry Quinn
0
gerryq (90)
4/8/2006 11:48:32 AM
yes, clicking on it should take to the allocating line in code.

-- 
Vipin Aravind
http://www.explorewindows.com


"Gerry Quinn" <gerryq@DELETETHISindigo.ie> wrote in message 
news:MPG.1ea1b36b3817be7c98ad0a@news1.eircom.net...
> In article <NuidndBQTJT_t6rZRVn-jw@comcast.com>, pesso@no.where says...
>> My debug build of program dumps the following in the trace when 
>> terminated:
>>  Detected memory leaks!
>>  Dumping objects ->
>>  {153} normal block at 0x00386AA8, 12 bytes long.
>>   Data: <hh8         > 68 68 38 00 00 00 00 00 06 00 00 00
>>  {152} normal block at 0x00386A68, 16 bytes long.
>>   Data: <                > 00 00 00 00 00 00 00 00 00 00 00
>>
>> Where do I start looking for the memory leak? Is there any way to track 
>> the
>> address to a corresponding object?
>
> Doesn't clicking on the error message often take you to where the
> memory was allocated, or am I imagining things?
>
> If not, at least you know how big the object is, which may be a clue.
>
> - Gerry Quinn 


0
vipin (697)
4/8/2006 3:11:36 PM

Pesso wrote:

> My debug build of program dumps the following in the trace when terminated:
>  Detected memory leaks!
>  Dumping objects ->
>  {153} normal block at 0x00386AA8, 12 bytes long.
>   Data: <hh8         > 68 68 38 00 00 00 00 00 06 00 00 00
>  {152} normal block at 0x00386A68, 16 bytes long.
>   Data: <                > 00 00 00 00 00 00 00 00 00 00 00
> 
> Where do I start looking for the memory leak? Is there any way to track the 
> address to a corresponding object? 

Add this at the beginning of your .cpp files:

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif //_DEBUG

Then your debug line will start looking like:

c:\cpp\..\dev.cpp(72) :  {153} normal block at 0x00386AA8, 12 bytes long.
    Data: <hh8         > 68 68 38 00 00 00 00 00 06 00 00 00

That is the file and line number of the 'new' that didn't get deleted. 
Then, as has been said, double clicking will take you to the line.

Best, Dan.

-- 
"We need an energy policy that encourages consumption"
George W. Bush.

"Conservation may be a sign of personal virtue, but it is not a 
sufficient basis for a sound, comprehensive energy policy."
Vice President Dick Cheney

0
public21 (290)
4/8/2006 5:08:43 PM
>yes, clicking on it should take to the allocating line in code.

But in this case the file and line number aren't available, so that's
not possible.

Dan's suggestion, or the information at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_CRT__CRTDBG_MAP_ALLOC.asp
may help. There's still the likelihood that the allocation is in some
common code and only 1 usage of that code is the problem. In those
cases it's best to see if the allocation number is consistent between
test runs, and if it is, break on that.

Dave
0
davidl7375 (2060)
4/8/2006 5:33:07 PM
In message <NuidndBQTJT_t6rZRVn-jw@comcast.com>, Pesso <pesso@no.where> 
writes
>Where do I start looking for the memory leak? Is there any way to track the
>address to a corresponding object?

Memory Validator.       http://www.softwareverify.com
Download the tutorial as well when you download the evaluation.

Stephen
-- 
Stephen Kellett
Object Media Limited    http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
0
snail (185)
4/10/2006 11:08:56 AM
Reply:

Similar Artilces:

Debug Assertion Faild
Debug Assertion Fail Program: C:..... File: winocc.cp Line: 22 The exception Breakpoin A breakpoint has been reache (0x80000003) occurred in the application at location 0x5f4369c This program is to scan a file and look for a matching string. Could this error be caused by code not exiting a "break;" properly? I'm not sure how to explore resolving this. The information listed in the Debug is The thread 0x3DD8 has exited with code 0 (0x0) The thread 0x3EA8 has exited with code -2147483645 (0x80000003) The program 'C:\Documents and Settings\Owner\My Documents\Dads\Programmi...

DEBUG
Curious, new problem has started. Evey once in a whle a new folder appears on my desktop labeled "debug"..The folder is empty and I do not know how it is formed or why..Does someone know the cause of this and a remedy so it does not appear again Thanks Running Xp professtional heshie wrote: > Curious, new problem has started. Evey once in a whle a new folder appears on > my desktop labeled "debug"..The folder is empty and I do not know how it is > formed or why..Does someone know the cause of this and a remedy so it does > not appear again &g...

How to delocate memory
Hi all, I new a variable like the following , becasue I do not know how much money he has, so I left the array count blank! char * client_money = new char[]; then I use the following statement to assign the value to the char array like : ltoa(rd_rec.clMoney,jine,10); ... ... I want to free the memory after using the varible , how to do? thanks to any helpful ideas! -ja "ja" <josndrsn@yahoo.com> wrote in message news:uu$6bY1HHHA.4056@TK2MSFTNGP03.phx.gbl... > I new a variable like the following ,...

MFC and database
Hi All, I am writing a software application that executes 24/7. While running, there is a need to collect production data [realtime] in a database so that later it can be sent to a server [PC] and be graphed. The software on the PC expects the data to be in SQL. I am coding with eMbedded Visual C++ and using of course Win CE 3.0. What technologies do I need to use to accomplish this task ? OLEDB ? ... Do I need Windows CE SQL Server or something similar ? I also need to synchronize my data with the server (PC) that would be running Windows 2K... In summary, the questions are: 1) What sho...

The instruction at "ox30033d8a" referenced memory
I receive the message "The instruction at "ox30033d8a" referenced memor at "ox650918d8". The memory could not be "read". " when i close th excel file from VBA code like WB.clos -- sandy ----------------------------------------------------------------------- sandya's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3781 View this thread: http://www.excelforum.com/showthread.php?threadid=57375 ...

An application crashes only under debugging
Hi, I'm using VC++ 6.0. I have a Win32 Application (I will call it "EXE") which is linked with a Win32 DLL and I don't have the source files of the DLL; When I execute the EXE by double-clicking on the icon reprsenting it , there are no problems; On the contrary, if I try to debug the EXE the program crashes: in fact, the debugger shows an "Access Violation" error message and informs that an istruction of the DLL attempts to read a memory location which cannot be read. Does someone know a possible cause of this problem? Thanks. M If the DLL is an MFC DLL (it is...

Weird: CRichEditCtrl scrollbars work in debug build but not in release build
Hi, I have an App Wizard project (VS 6.0), non doc-view architecture. My view class is: class CRichTextView : public CRichEditCtrl. In MainFrm.cpp I have a member variable of: CRichTextView m_wndView;. I create the view as follows: if (!m_wndView.Create(WS_CHILD | WS_VISIBLE | ES_AUTOVSCROLL | ES_MULTILINE | WS_VSCROLL, CRect(0,0,0,0), this, AFX_IDW_PANE_FIRST)) { TRACE0("Failed to create view window\n"); return -1; } It works "just peachy" in the debug build. But, when I make...

Memory problem
Hi i have quite huge excell file with pivot tables, I generate every day raports from it, however today I have got message like: Not enough memory and then error with accessing Access database which is probably related to memory problem. Do you know what kind of memory does excell use ? What should I change or how can I check where is the problem ? regards Peter ...

Debug in Release mode?
Old wine in old bottle.. being served by a new bartender :o) How do I do this? pointer would be much appreciated. >Old wine in old bottle.. being served by a new bartender :o) > >How do I do this? The subject or the content? To debug a release build see "How to: Debug a Release Build" in your VC++ help. Dave In addition to what Dave suggested you might want to just do a find on this newsgroup using those keywords. There have been several discussions on that topic in the last few days that should pop up a bunch of links. If you can't find them let me know and ...

Excel 2007 Out of Memory Errors
I've had several users encounter the same errors when having Excel 2007 open for an hour or two. They get errors such as 'not enough system resources to display completely' or 'excel cannot complete this task with available resources. Choose less data or close other'. Also, the screen seems to 'hang' up or buttons on the excel bar disappear, etc. All these users are running new computers with 4 GB ram, dual dual-core processors, and XP SP3 with all the latest updates. We have exact the same problem on differen machines 2-4GB RAM. I found the following li...

Localisation of MFC application
Hi I am developing an MFC application. I want to know what are the requirements for the localisation of my application to Chinese and Korean. I want all my text box, menu and message box text must come into Chinese and korean language. What are basic steps needed for including the localisation facility into my project? Is there any basic location/site where i can find translation of basic menu item converted into chinese literals i.e. converting File-> Open to Blah->Blash in chinese and korean. (Lang. translation) Hope for reply Thanks in advance Sandeep Arya ...

Very strange debugging problem
I have a windows console program that interfaces with a library that interfaces with a hardware device. I run the same unmodified program with the same input and get different results on different trials. My program is the same, the test data is the same, yet different runs produce different results. There are only two sorts of things that I can think of that could cause this: (1) The state of the hardware device changes between runs. (2) Some really weird memory error that causes my program to run correctly 75% of this time and fail other times. Does anyone have any ideas on how I ca...

Outlook using 36MB of memory???
My computer seems quite sluggish this morning, and when I checked the task manager it says that Outlook is using more than 35,990 KB of memory. What's happening?? Tehe, mine is taking up 118MB at the moment :-D It really depends on what version of Outlook you are running, the account type(s) being used, the size of your mailbox and installed add-ins. -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -Backup and Restore -Create an Office XP CD slipstreamed with Service Pack 3 ----- "Greg1" <anonymous@discussions.microsoft.com> wrote in mess...

Vba Memory
I am trying to run a macro and it says Microsoft Visual Basic Out of Memory. Can I reset or clear the memory somehow? -- billy2willy ------------------------------------------------------------------------ billy2willy's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=21648 View this thread: http://www.excelforum.com/showthread.php?threadid=396246 There is a problem with your VB code if you are getting that error message. "billy2willy" wrote: > > I am trying to run a macro and it says Microsoft Visual Basic Out of > Memory. Can I reset or ...

Debugging
Hi, I have an access violation in my program when closing, apart from that things are working in debug mode. This is difficult to deal due to a lack of information. One message I get is as below, is there anyway to turn this into something meaningful? Heap block at 009B1C68 modified at 009B2370 past requested size of 700 The stack trace shows ntdll! 77f75a58() What can I use to track problems like this down? I must be accessing restricted memory during the deallocation of objects or misusing the mfc, I do not know, though there does not appear to be any memory leaks. I did have memor...

About Event Handling in MFC
Dear All, I am facing a wierd problem using MFC. Actaully, I have to exit a while loop on a button click. The while loop constantly checks for a boolean variable whose value is to be modified when ever a button of CButton class is clicked. I have done the follwing things but they dont seem to work. In DoDataExchange function: DDX_Control(pDX, IDC_Z_START_SEQUENCE, m_StartSequence); In BEGIN MESSAGE MAP ON_BN_CLICKED(IDC_Z_START_SEQUENCE, OnZStartSequence); void CZMotorCtrlWithUSB::OnZStartSequence() { startSequencing = !startSequencing; //startSequencing is initially false Sequence...

remote debugging
Hi, I am using VC++ 6.0's remote debugger. It keeps complaining that the remote machine could not be found. I defined the remote machine as \\sty-401 or R: (a map drive that is equivalent to \\sty-401) in menu->Build->Debugger remote connection->Settings->Target machine name. I can access the machine by typing either \\stry-401 or R: in the windows explorer. That means the access has no problem. Can someone help me out? Thanks. Tony "JD" <jdt_young@yahoo.com> wrote in message news:etml8qy7GHA.3604@TK2MSFTNGP02.phx.gbl... > Hi, > > I am ...

XmlSerializer produces different results in debug and release buil
A few weeks ago, I upgraded an XML server of ours to .NET 2.0. All went fine. Then last week, I decided to remove all obsolete calls from the app and sign each project in the solution in the .NET 2 way so that the app compiled with no warnings. This built fine but we noticed that server was deserializing one of our XML messages incorrectly. I confirmed via source control that neither the schemas themselves nor the classes representing the messages had been altered but the problem continued. After some investigation, I found I could I could actively switch this bug on and off in debug mod...

Changing default text colour on MFC group box...
Hi there, I'm using VC++ 6.0. My application uses a manifest file to get the XP look and feel. I have an overridden group box control, but can't seem to change the default blue text colour. Here's my CtlColor override... HBRUSH CArkFrame::CtlColor(CDC* pDC, UINT nCtlColor) { UNREFERENCED_PARAMETER(nCtlColor); pDC->SetBkMode(OPAQUE); pDC->SetBkColor(RGB(255, 255, 255) ); pDC->SetTextColor(RGB(0, 0, 0) ); return m_hbBackground; } The background brush returned works fine, but the text color will not change no matter how much dancing I do. Does anyone know of any w...

How we can insert payment button in to yahoo ,hotmail email message using a Payment wizard application which is developed using VC++(MFC)
hi Actually i developed a payment wizard application using VC++(MFC) which insert payment buttons in to outlook email messages after then we send that mail to customer when customer open his mail he found payment button in his mail when he click on that button he automatically log on to www.paypal.com , but i want to use the same wizard application to insert payment button in to yahoo and hotmail email messages. so can some body help me in finding the solution. if possible provide code also. Rajeev ...

Debug
Hi, How can i debug a lib file that link to my project from my project in debug mode??? (i been told that i need to insert the file of the lib to my project and so.. how to do it???") Thanks. To do it easily you have to have the source for the lib adn have the lib compiled in debug mode as well. Adding the project for the lib to your solution makes this pretty easy to do. Tom "Dave" <dbg@012.net.il> wrote in message news:eR1dbIBoEHA.3684@TK2MSFTNGP10.phx.gbl... > Hi, > How can i debug a lib file that link to my project from my project in debug > mode??? &...

Using MFC with another compiler mingw
Hi, I would like to know if it's possible to compile a normal MFC application with mingw (gcc) by converting it to WFC (By SamBlackBurn). Vince wrote: > Hi, > > I would like to know if it's possible to compile a normal MFC > application with mingw (gcc) by converting it to WFC (By SamBlackBurn). > You should consider that to be a complete rewrite of the application. -- Scott McPhillips [VC++ MVP] In addition to what Scott says, I would add "no". I guess, maybe that's not entirely accurate. It is "possible", it would just be an incre...

How to change startup form in vc++ MFC
hi friends, can anyone tell me how i can change form which starts first in vc++ mfc, actuallly i am inserting a form but whenever i run a program it will start default form and i need to run my form which i have inserted.... hardik wrote: > hi friends, > can anyone tell me how i can change form which starts > first in vc++ mfc, > actuallly i am inserting a form but whenever i run a program it will > start default form and i need > to run my form which i have inserted.... Is this a dialog based application? If so, the initial form is determ...

How to Reduce Memory requirement of large Excel workbooks ?
I'm working with large Excel spreadsheets and running into problem with the size of it. Currently it is around 45 MB and getting unstable. Is there anything I can do to reduce the memory requirements in Excel ? I'm having around 3000 rows and 300 columns of data split on a few input sheets. Then, there are lots of analysing sheets with calculations like divisions, multiplications and lookupfunctions and if-statements and plots. Should I avoid formatting, does the data organising impact the memory (formulas link between sheets etc.), is multiplication less demaning than division, w...

Outlook stays in memory
If I go in and out of Outlook a number of times a day, I notice that my available memory gets continually lower. If I bring up my task manager, there a a number of references for Outlook. If I delete the referrences, my available memory recovers. Any ideas why htis has started? Thansk. ...