Jump to content
Software FX Community

Correct object destruction


User (Legacy)
 Share

Recommended Posts

Do I need to worry about object descruction?

I am using ChartFX client server in MFC and have noticed in the

DestroyWindow method:

BOOL CCfxXYChart::DestroyWindow()

{

// TODO: Add your specialized code here and/or call the base class

m_pChartFX = NULL;

return CDialog::DestroyWindow();

}

There is a setting of the object to NULL, but no releasing of the object

or anything else. Do I need to worry?

A program that I use to detect memory leaks is reporting that some

memory is being leaked when running the MFC sample.

Link to comment
Share on other sites

If the chart is inside a container, it will automatically be destroyed when 

the container is destroyed assuming you don't have any COM references to it

(AddRef, QueryInterface), if you use smart pointers, the Release calls will

occur automatically when the C++ object is deleted (destructor is called)

Setting the Smart Pointer to null will also cause a Release, as a matter of

fact you can debug this and check the return value of the Release call, the

last one should return ZERO (0), if it is not zero it means you still have a

reference.

--

FP

Software FX

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...