Click here to Skip to main content
15,919,341 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Decimal Symbol Pin
PJ Arends12-Mar-03 10:08
professionalPJ Arends12-Mar-03 10:08 
GeneralRe: Decimal Symbol Pin
Haakon S.12-Mar-03 10:59
Haakon S.12-Mar-03 10:59 
Generalmfc ActiveX control install issue Pin
work_to_live11-Mar-03 9:04
work_to_live11-Mar-03 9:04 
GeneralRe: mfc ActiveX control install issue Pin
Dave Bryant11-Mar-03 9:38
Dave Bryant11-Mar-03 9:38 
GeneralRe: mfc ActiveX control install issue Pin
work_to_live11-Mar-03 11:59
work_to_live11-Mar-03 11:59 
GeneralPassing Variables from Macromedia Director to C++ Pin
moojuice11-Mar-03 9:03
moojuice11-Mar-03 9:03 
GeneralRe: Passing Variables from Macromedia Director to C++ Pin
moojuice13-Mar-03 7:24
moojuice13-Mar-03 7:24 
QuestionDoes this code leaks memory? Pin
Joan M11-Mar-03 8:49
professionalJoan M11-Mar-03 8:49 
Hello,

I'm debugging my last program... and today I've acquired Rational Purify (trial version) in order to receive help on this task...

after running my program under Rational Purify, I've found some memory leaks... but now I'm not sure of which is my name (almost)...

let's see, it says that this code is leaking memory:
-------------------------------------------------------------
-------------------------------------------------------------
// Variables que permeten la construcció del codi HTML.
CString csCodiHTML = "HTML STRING...";
BSTR bstr;

int iWidthAreaClientHTMLCtrl = 0;

// Tractament del SafeArray.
HRESULT hrTractarAmbSafeArray = S_OK;

SAFEARRAY *pSafeArray = NULL;
VARIANT *pElement = NULL;

extern CTCCApp TCCApp;

//------------------------------------------------
// Obtenir accés al control HTML via ATL.
//------------------------------------------------
CComQIPtr<IHTMLDocument2> spHTMLDocument = this->m_HTMLCtrl.GetHtmlDocument();

if(spHTMLDocument)
{
CComQIPtr<IHTMLElement> spHTML;

spHTMLDocument->get_body(&spHTML);

if (spHTML)
{
bstr = csCodiHTML.AllocSysString();

spHTML->put_innerHTML(bstr);

spHTML.Release();

SysFreeString(bstr);
csCodiHTML.ReleaseBuffer();
csCodiHTML.FreeExtra();
}
else
{
pSafeArray = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);

if (pSafeArray)
{
hrTractarAmbSafeArray = ::SafeArrayAccessData(pSafeArray,(LPVOID*) &pElement);

pElement->vt = VT_BSTR; // HERE!
pElement->bstrVal = csCodiHTML.AllocSysString();

hrTractarAmbSafeArray = ::SafeArrayUnaccessData(pSafeArray);

hrTractarAmbSafeArray = spHTMLDocument->write(pSafeArray);

::SafeArrayDestroy(pSafeArray);

csCodiHTML.ReleaseBuffer(); // HERE TOO!
csCodiHTML.FreeExtra();
}
}
}

if (spHTMLDocument) spHTMLDocument.Release();
-------------------------------------------------------------
-------------------------------------------------------------
Where you can see HERE! and HERE TOO! is where that program Rational purify is detecting some memory leaks... do you think that the code is leaking memory?

and if so... why? I thought that if I have not called new I should'nt call delete and that whenever the function goes out of scope the local variables are destructed automatically... isn't it true?

Thank you in advance...
AnswerRe: Does this code leaks memory? Pin
Tim Smith11-Mar-03 8:56
Tim Smith11-Mar-03 8:56 
GeneralRe: Does this code leaks memory? Pin
Daniel Turini11-Mar-03 9:00
Daniel Turini11-Mar-03 9:00 
GeneralRe: Does this code leaks memory? Pin
Joan M11-Mar-03 20:39
professionalJoan M11-Mar-03 20:39 
GeneralRe: Does this code leaks memory? Pin
Tim Smith11-Mar-03 9:23
Tim Smith11-Mar-03 9:23 
AnswerRe: Does this code leaks memory? Pin
Rob Groves12-Mar-03 10:52
Rob Groves12-Mar-03 10:52 
GeneralDirectShow - CBaseControlWindow(BaseClasses) Pin
Jakub Misek11-Mar-03 8:09
Jakub Misek11-Mar-03 8:09 
GeneralConvert BITMAP to JPEG Pin
Emiliano11-Mar-03 8:05
Emiliano11-Mar-03 8:05 
GeneralRe: Convert BITMAP to JPEG Pin
Larry Antram11-Mar-03 8:09
Larry Antram11-Mar-03 8:09 
GeneralConvert Screen Rect to Printer Rect Pin
Gilfrog11-Mar-03 7:46
Gilfrog11-Mar-03 7:46 
GeneralRe: Convert Screen Rect to Printer Rect Pin
Nitron11-Mar-03 7:55
Nitron11-Mar-03 7:55 
GeneralRe: Convert Screen Rect to Printer Rect Pin
Gilfrog11-Mar-03 8:08
Gilfrog11-Mar-03 8:08 
GeneralMFC42D.DLL not found !!! Pin
ZarrinPour11-Mar-03 7:34
ZarrinPour11-Mar-03 7:34 
GeneralRe: MFC42D.DLL not found !!! Pin
User 665811-Mar-03 7:59
User 665811-Mar-03 7:59 
Generalw2000 & w98 Pin
doctorpi11-Mar-03 7:27
doctorpi11-Mar-03 7:27 
GeneralRe: w2000 & w98 Pin
Mike Nordell11-Mar-03 19:33
Mike Nordell11-Mar-03 19:33 
GeneralWindow Pin
wanju11-Mar-03 6:42
wanju11-Mar-03 6:42 
GeneralRe: Window Pin
Big Art11-Mar-03 7:01
Big Art11-Mar-03 7:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.