Skip to content

There should be implemented a WeakPtr also #11

@Q-Master

Description

@Q-Master

This code will leak because a refers to b and b refers to a and there's no possibility to fix this not using WeakPtr.

import threading/smartptrs

type
  Widget = object
    oth: SharedPtr[Widget]


var a: SharedPtr[Widget] = newSharedPtr(Widget())
var b: SharedPtr[Widget] = newSharedPtr(Widget())
a[].oth = b
b[].oth = a
echo a
echo b

Also this code goes to infinite recursion in echos.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions