CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 1 of 1

Thread: weak_ptr problem

  1. #1
    Join Date
    Dec 2010

    weak_ptr problem

    I have encountered a problem of cyclic reference in some of my programs that I wrote.
    When I changed that cyclic type to weak_ptr, the leaks were gone.
    However, when I used those weak_ptr's outside that module, the pointers expired.

    Any ideas I can solve that, similiar situation to this...
    (This crashes)

    Actually, the variable I used is in a loop, so that it is reset in each iteration.
    That's why the weak_ptr is expired.

    It's like when I loop thru the neighbours of the current node,
    one of the neighbours will replace the current node and
    the current node will open some neigbouring nodes again
    and so on so forth

    As a consequence, the final path which contains the transitions which in turn contains the nodes
    will be leaked, and all other invalid nodes that are not in the path will be automatically destroyed.
    if I use shared_ptr's, otherwise, using weak_ptr's will cause the nodes to be expired
    when the "current" node is reset.
    Attached Files Attached Files
    Last edited by lucky6969b; June 6th, 2016 at 10:07 AM.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)