Link to home
Start Free TrialLog in
Avatar of JenniferObrecht
JenniferObrecht

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial