Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:49:05+00:00 2026-06-14T09:49:05+00:00

This question has been bugging me for a while: I’ve read in MSDN’s DirectX

  • 0

This question has been bugging me for a while: I’ve read in MSDN’s DirectX article the following:

The destructor (of the application) should release any (Direct2D) interfaces stored…

DemoApp::~DemoApp()
{
    SafeRelease(&m_pDirect2dFactory);
    SafeRelease(&m_pRenderTarget);
    SafeRelease(&m_pLightSlateGrayBrush);
    SafeRelease(&m_pCornflowerBlueBrush);
}

Now, if all of the application’s data is getting released/deallocated at the termination (source) why would I go through the trouble to make a function in-order-to/and release them individually? it makes no sense!

I keep seeing this more and more over the time, and it’s obviously really bugging me.
The MSDN article above is the first time I’ve encountered this, so it made sense to mention it of all other cases.

Well, since so far I didn’t actually ask my questions, here they are:

  • Do I need to release something before termination? (do explain why please)
  • Why did the author in MSDN haven chosen to do that?
  • Does the answer differ from native & managed code? I.E. Do I need to make sure everything’s disposed at the end of the program while I’m writing a C# program? (I don’t know about Java but if disposal exists there I’m sure other members would appreciate an answer for that too).

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:49:06+00:00Added an answer on June 14, 2026 at 9:49 am

    You don’t need to worry about managed content when your application is terminating. When the entire process’s memory is torn down all of that goes with it.

    What matters is unmanaged resources.

    If you have a lock on a file and the managed wrapper for the file handler is taken down when the application closes without you ever releasing the lock, you’ve now thrown away the only key that would allow access to the file.

    If you have an internal buffer (say for logging errors) you may want to flush it before the application terminates. Not doing so would potentially mean the fatal error that caused the application to end isn’t logged. That could be…bad.

    If you have network connections open you’ll want to close them. If you don’t then the OS likely won’t do it for you (at least not for a while; eventually it might notice the inactivity) and that’s rather rude to whoever’s on the other end. They may be continuing to listen for a response, or continuing to send you information, not knowing that you’re not there anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a question that has been bugging me for a while. I started
This is a question that has been bugging me for a while and I
This question has been bugging me for a while. I am looking for a
This question has been bugging me for a while now. When writing a CSS
This question has been bugging me for a while Is it usual to have
This question has been bugging me for a long time now but essentially I'm
This question has been bugging me for some time. I always picture launching my
This question has been bugging me for some time. I've already developed a couple
It's not a programming questions. But this question has been bugging me for awhile.
This question has been bugging me a LOT lately. Any help would be appreciated.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.