Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project i never used new delete malloc calloc for any operation.
i used new operator only once to create object of xyz class in winmain() & free that object while exiting the project.

i had use vmr, vfw, gdi gdi plus ,icon instead of normal button in my application

after playing each new video memory is increases( in task manager)
even some times when i move mouse or click left button mem increases

how should i find is there any memory leak.

below code is used to textual display when cursor is move to any two icon(HOME & EXIT)
case WM_MOUSEMOVE:
{
HWND hwButton_home=GetDlgItem(g_hDialogWindow,IDC_ICON_HOME);
HWND hwButton_exit=GetDlgItem(g_hDialogWindow,IDC_ICON_EXIT);

WINDOWPLACEMENT lpwndpl_home;
WINDOWPLACEMENT lpwndpl_exit;

GetWindowPlacement(hwButton_home,&lpwndpl_home);
GetWindowPlacement(hwButton_analyze,&lpwndpl_exit);


		
if( ((lpwndpl_home.rcNormalPosition.left)<LOWORD(lParam)&& LOWORD(lParam)<(lpwndpl_home.rcNormalPosition.right)) && ((lpwndpl_home.rcNormalPosition.top)<HIWORD(lParam)&& HIWORD(lParam)<(lpwndpl_home.rcNormalPosition.bottom)))
{
if(IsWindowEnabled(hwButton_home))
{
 ::SetWindowPos(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), HWND_NOTOPMOST,  lpwndpl_home.rcNormalPosition.left,  lpwndpl_home.rcNormalPosition.bottom, 45,18, SWP_NOZORDER);      
  SetWindowText(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), "HOME");
   ShowWindow(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), TRUE);

}
}

else if( ((lpwndpl_exit.rcNormalPosition.left)<LOWORD(lParam)&& LOWORD(lParam)<(lpwndpl_exit.rcNormalPosition.right)) && ((lpwndpl_exit.rcNormalPosition.top)<HIWORD(lParam)&& HIWORD(lParam)<(lpwndpl_exit.rcNormalPosition.bottom)))
{	
if(IsWindowEnabled(hwButton_exit))
 {
::SetWindowPos(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), HWND_NOTOPMOST,  lpwndpl_exit.rcNormalPosition.left+5,  lpwndpl_exit.rcNormalPosition.bottom, 75,18, SWP_NOZORDER);      
   SetWindowText(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), "EXIT");
 ShowWindow(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), TRUE);

}
  }

else
                
ShowWindow(GetDlgItem(g_hDialogWindow, IDC_MODE_TEXT), FALSE);
}
break;

when i placed mouse on this icon 4 bytes of meme increases.
Posted
Updated 11-Jan-12 21:18pm
v3

The API functions you are calling may also allocate memory. This memory is freed when the objects are destroyed. As already noted, you can't be sure that there are memory leaks when the used memory increases during operation. Only when there is unfreed memory upon application termination, you have memory leaks.

With debug builds, you may call AfxCheckMemory() within ExitInstance() of your CWinApp derived class to check the heap. But this will not detect all leaks.
 
Share this answer
 
As stated. Task Manager doesn't reliably show you memory leaks. Since the number in task manager is increasing, try this - it will help see if there really is a leak.

Run your application and look at the task manager as the values increase. Next, minimize your application to the task bar. If the memory in the task manager drops back to what appears "normal", you probably don't have any leaks.

Minimizing the application causes the OS to release the working set memory. As your app uses memory, that addtional memory is put in a "working set" and not immediately released when it isn't needed - it's held in case you need it again. It would be released if needed by something else in the OS. Minimizing causes the OS to release that memory.

Hope that helps.
 
Share this answer
 
memory increasing in task manager is not directly evidence of memory leaking.
if you make sure it is your program's issue, some tools may help e.g. boundsChecker
 
Share this answer
 
Comments
Mohibur Rashid 12-Jan-12 3:06am    
that software has mind blowing review ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900