Solved

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

Posted on 2006-11-20
1
1,035 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

634 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