Click here to Skip to main content
15,920,956 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Regular expression Pin
Demian Panello13-Mar-09 14:19
Demian Panello13-Mar-09 14:19 
QuestionI Think I need to free Something Pin
BobInNJ13-Mar-09 11:38
BobInNJ13-Mar-09 11:38 
AnswerRe: I Think I need to free Something Pin
Stuart Dootson13-Mar-09 13:54
professionalStuart Dootson13-Mar-09 13:54 
GeneralRe: I Think I need to free Something Pin
BobInNJ14-Mar-09 13:16
BobInNJ14-Mar-09 13:16 
GeneralRe: I Think I need to free Something Pin
Stuart Dootson14-Mar-09 13:24
professionalStuart Dootson14-Mar-09 13:24 
GeneralRe: I Think I need to free Something Pin
BobInNJ14-Mar-09 14:16
BobInNJ14-Mar-09 14:16 
GeneralRe: I Think I need to free Something Pin
Stuart Dootson14-Mar-09 18:53
professionalStuart Dootson14-Mar-09 18:53 
QuestionMemory Leakege Reporting without line number Pin
Member 349347313-Mar-09 11:09
Member 349347313-Mar-09 11:09 
Hello,

I used Visual Studio's tools for reporting memory leaks.

Main program uses a dll. In main program it reports the file name and line number:

d:\tmp\ali\ali\ali.cpp(47) : {200} client block at 0x003A84C0, subtype 0, 5000 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD

but in dll it doesn't:

{199} normal block at 0x003AC018, 10000 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD


This style reporting isn't usefull for me.

What's wrong here. How can i fix this problem.

thanks!!




Exe Source Code:
#include "stdafx.h"

#ifdef _DEBUG
   #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__)
#else
   #define DEBUG_CLIENTBLOCK
#endif // _DEBUG

#if defined(_DEBUG) && defined(WIN32)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif

#include <windows.h>
#include <conio.h>


#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif



int _tmain(int argc, _TCHAR* argv[])
{
	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	HINSTANCE m_kutuphane = LoadLibrary(L"DebugDLL.dll");

	typedef __declspec(dllimport) void __stdcall MyDllFunction();
        
    char	getDllFunctionName[]="?dllFunction@@YAXXZ";
    
    
    MyDllFunction*  mf = NULL;
    
    
    
    mf = (MyDllFunction *) GetProcAddress(m_kutuphane,getDllFunctionName);
    
    
    mf();

    new char[5000];

    while (!_kbhit());

    return 0;
}
</conio.h></windows.h></crtdbg.h></stdlib.h>




Dll Source Code:
// Check for memory leaks

#if defined(_DEBUG) && defined(WIN32)
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{

	//_crtBreakAlloc = 1397;
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
    return TRUE;

	new char[10000];
}

__declspec( dllexport ) void dllFunction() 

{
	std::cout << "dll: Hello!" << std::endl;
	//Memory leakage
	new char[10000];
	
}</crtdbg.h></stdlib.h>





Output :

'ali.exe': Loaded 'D:\tmp\ali\debug\ali.exe', Symbols loaded.
'ali.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'ali.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'ali.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcr80d.dll', Symbols loaded.
'ali.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'ali.exe': Loaded 'D:\tmp\ali\debug\DebugDLL.dll', Symbols loaded.
'ali.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcp80d.dll', Symbols loaded.
Detected memory leaks!
Dumping objects ->
d:\tmp\ali\ali\ali.cpp(47) : {200} client block at 0x003A84C0, subtype 0, 5000 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
{199} normal block at 0x003AC018, 10000 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
The program '[5988] ali.exe: Native' has exited with code 0 (0x0).



Compiler settings:

Exe:

/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Yu"stdafx.h" /Fp"Debug\ali.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt

Dll:

/Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "DEBUGDLL_EXPORTS" /D "_UNICODE" /D "UNICODE" /D "_WINDLL" /Gm /EHsc /RTC1 /MDd /Yu"stdafx.h" /Fp"Debug\DebugDLL.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt


Linker settings:

Exe:

/OUT:"D:\tmp\ali\Debug\ali.exe" /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"Debug\ali.exe.intermediate.manifest" /DEBUG /PDB:"d:\tmp\ali\debug\ali.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Dll:

/OUT:"D:\tmp\ali\Debug\DebugDLL.dll" /INCREMENTAL /NOLOGO /DLL /MANIFEST /MANIFESTFILE:"Debug\DebugDLL.dll.intermediate.manifest" /DEBUG /PDB:"d:\tmp\ali\debug\DebugDLL.pdb" /SUBSYSTEM:WINDOWS /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib





AnswerRe: Memory Leakege Reporting without line number Pin
Stuart Dootson13-Mar-09 13:50
professionalStuart Dootson13-Mar-09 13:50 
GeneralRe: Memory Leakege Reporting without line number Pin
Member 349347314-Mar-09 11:27
Member 349347314-Mar-09 11:27 
Questionhow do I, amend a bitmap a run time Pin
simon alec smith13-Mar-09 9:02
simon alec smith13-Mar-09 9:02 
QuestionRe: how do I, amend a bitmap a run time Pin
CPallini13-Mar-09 9:11
mveCPallini13-Mar-09 9:11 
AnswerRe: how do I, amend a bitmap a run time Pin
Hamid_RT13-Mar-09 19:48
Hamid_RT13-Mar-09 19:48 
QuestionI find an interesting and confusing code..have a look. Pin
JackPuppy13-Mar-09 8:39
JackPuppy13-Mar-09 8:39 
AnswerRe: I find an interesting and confusing code..have a look. Pin
led mike13-Mar-09 8:49
led mike13-Mar-09 8:49 
GeneralRe: I find an interesting and confusing code..have a look. Pin
JackPuppy13-Mar-09 8:55
JackPuppy13-Mar-09 8:55 
GeneralRe: I find an interesting and confusing code..have a look. Pin
David Crow13-Mar-09 8:58
David Crow13-Mar-09 8:58 
GeneralRe: I find an interesting and confusing code..have a look. Pin
JackPuppy13-Mar-09 9:03
JackPuppy13-Mar-09 9:03 
QuestionRe: I find an interesting and confusing code..have a look. Pin
David Crow13-Mar-09 9:07
David Crow13-Mar-09 9:07 
JokeRe: I find an interesting and confusing code..have a look. Pin
CPallini13-Mar-09 9:09
mveCPallini13-Mar-09 9:09 
GeneralRe: I find an interesting and confusing code..have a look. Pin
led mike13-Mar-09 9:03
led mike13-Mar-09 9:03 
GeneralRe: I find an interesting and confusing code..have a look. Pin
CPallini13-Mar-09 9:07
mveCPallini13-Mar-09 9:07 
GeneralRe: I find an interesting and confusing code..have a look. Pin
JackPuppy13-Mar-09 9:30
JackPuppy13-Mar-09 9:30 
GeneralRe: I find an interesting and confusing code..have a look. Pin
bulg13-Mar-09 10:35
bulg13-Mar-09 10:35 
GeneralRe: I find an interesting and confusing code..have a look. Pin
JackPuppy13-Mar-09 10:38
JackPuppy13-Mar-09 10:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.