CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2010
    Posts
    907

    What will happen if I brutally force to stop an application when ptrs are smart

    If I use smart pointers to protect my dynamically allocated objects,
    what will happen when I brutally stop an application,
    will the pointers leak?
    Thanks
    Jack

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: What will happen if I brutally force to stop an application when ptrs are smart

    Well, didn't you try to " brutally stop an application"?
    Victor Nijegorodov

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: What will happen if I brutally force to stop an application when ptrs are smart

    The Operating System will free memory owned by the application when it terminates, gracefully or otherwise.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: What will happen if I brutally force to stop an application when ptrs are smart

    Read up on TerminateProcess in msdn. Typically the OS frees everything, but not always.

  5. #5
    Join Date
    Jun 2009
    Location
    France
    Posts
    2,513

    Re: What will happen if I brutally force to stop an application when ptrs are smart

    Typically, everything is "freed", but not necessarily "cleanly". Files may not be flushed, temporary lock files may not be deleted, termination signals may not be sent etc...

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: What will happen if I brutally force to stop an application when ptrs are smart

    what will happen when I brutally stop an application,
    Why do you want to do this?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: What will happen if I brutally force to stop an application when ptrs are smart

    Also note that forcibly terminating a program does not call the destructor of any in-scope objects. It is a really bad idea to force terminate a process.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  8. #8
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Re: What will happen if I brutally force to stop an application when ptrs are smart

    It will Stop That's all

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured