I am using the activeX in a dialog in my MS VC6 project to display a
status screen. But over time there is a memory leak. The leak is
cleaned up when the control is destroyed at the end of the program so it
doesn't show up as an official leak but as long as I keep calling this
code I can watch TaskManager and see memory usage go up and up.
If I comment out this section of code the leak goes away.
The code is pretty simple, I build up the html to be displayed and then
execute the following code during a timer event.
NOTE:
pDoc is a global so I only have to get it once.
doc is a global char* with my HTML in it.
SAFEARRAY *sfArray;
VARIANT *param;
BSTR bstr;
bstr_t bs;
if ( pDoc == NULL ) {
pDoc = (MSHTML::IHTMLDocument2*)m_wbBrowser.GetDocument();
}
if ( pDoc != NULL ) {
bs = doc;
bstr = SysAllocString( bs );
sfArray = SafeArrayCreateVector(VT_VARIANT, 0, 1);
if ( sfArray != NULL ) {
SafeArrayAccessData(sfArray,(LPVOID*) & param);
param->vt = VT_BSTR;
param->bstrVal = bstr;
SafeArrayUnaccessData(sfArray);
pDoc->write( sfArray );
pDoc->close();
SafeArrayDestroy(sfArray);
}
SysFreeString(bstr);
}
Thanks in advance for any help!!!
