Solved

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

Posted on 2006-11-20
1
1,022 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 125 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
paragon account problem 9 96
deburging in oracle form 12 76
centeredAverage challenge 8 120
wordcount challenge 11 73
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now