Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-11-20
1
Medium Priority
?
1,043 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
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

927 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