Solved

Memory leaks detected using custom activeX control in VC++2005

Posted on 2006-11-20
1
1,033 Views
Last Modified: 2013-11-20
I am new to com and am trying to write a custom activeX control wrapped around third party activeX control.  I am using VC++ 2005 (no CLR support) and need to use the control in vb6, vc++6, vb.net and vc++2005.

When using my activeX control in MFC VC++2005 dialog project - I am getting detected memory leak error from plex.cpp and occmgr.cpp when closing out the test program :

From output window:
Info: AfxDllCanUnloadNow returning S_OK
Detected memory leaks!
Dumping objects ->
f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29) : {154} normal block at 0x0031FA60, 124 bytes long.
 Data: <              1 > 00 00 00 00 00 00 00 00 00 00 00 00 20 FA 31 00
f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\occmgr.cpp(788) : {153} normal block at 0x0031FA20, 4 bytes long.
 Data: < o0x> 9C 6F 30 78
{76} client block at 0x00313208, subtype c0, 64 bytes long.
a CDynLinkLibrary object at $00313208, 64 bytes long
a CDynLinkLibrary object at $00313208, 64 bytes long
Object dump complete.
...
...
The program '[1832] TestPV.exe: Native' has exited with code 0 (0x0).

I do not see this when using the control in VC++6 -
Code from output window:
Info: AfxDllCanUnloadNow returning S_OK
The thread 0x860 has exited with code 0 (0x0).
The program 'D:\DVLP\VC\TestPV6\Debug\TestPV6.exe' has exited with code 0 (0x0).

Also, I do not see this when using the control in VB.NET.

Steps I took to create the control (simplified) -
1.  Created ActiveX control through the wizard (MFC ActiveX control)
2.  Project properties - changed from unicode to multi-byte
3.  AfxEnableControlContainer() in InitInstance
4.  Added wrapper classes by adding class via ActiveX control ocx file
5.  Added resource symbol
6.  Added var of class type and included header
7.  OnCreate - created using .Create and OnDestroy - added delete
8.  Commented out the FillRect and Ellipse code in the OnDraw and added OnSize handler with MoveWindow and ShowWindow

Any help would be greatly appreciated.
Thanks.
0
Comment
Question by:JenniferObrecht
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 125 total points
ID: 17981886
Add the follwing line to program initialization code:

_CrtSetBreakAlloc(153);

and run the program. It breaks on allocation number 153, which is not released in the end. This can give you idea what happens. Do the same with {154}.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question