-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--gc:arc doesn't detect cycle, leaks memory; {.cursor.} ineffective with seq
#13080
Comments
covered by other bug reports plus arc doesn't deal with cycles by design. |
not seeing which bug report it's covered by in this list: |
@timotheecour ARC already warns when it detects cycles though |
For type
Node = ref object
next: Node
let a = Node()
a.next = a
echo a[]
|
@Yardanico did you read this bug report? as mentioned in the 1st sentence,
=> no warning |
There are no known algorithms that can reliably detect all cycles, I only know about heuristics. |
can we reopen?
no heuristics needed for those |
You can always use |
I'd like to understand more;
|
It can have significant runtime overhead (~25% for the "havlak" benchmark) but the |
But here the object is not acyclic so (I've retried all those examples with devel 1.5.1 338602a) |
seq
BUG1
--gc:arc doesn't detect cycle through a seq element, leaks memory, in
-d:case3
belowBUG2
x3 {.cursor.}: seq[Foo]
doesn't remove the leak through a seq element, see belowExample
Current Output
nim c -r -d:case1 main.nim
nim c -r -d:case2 main.nim
nim c -r -d:case3 main.nim
uses 6.121MiB
nim c -r --gc:arc -d:case1 main.nim # ok
=> leaks 1.412GiB
nim c -r --gc:arc -d:case2 main.nim # ??
not sure whether that's what we want here:
=> leaks: 1.475GiB
nim c -r --gc:arc -d:case3 main.nim
BUG: compiler doesn't tell you there's a cycle, no warnings/hints shown
=> leaks: 1.475GiB
Expected Output
compiler should tell you there's a cycle (and, as enhancement: either saying "surely a cycle" or "maybe a cycle" depending on the case)
Additional Information
devel 5e9ebe9
for case1, using
x2 {.cursor.}: Foo
would remove leak and consume only 516KiB instead of 6.09MiB without --gc:arcThe text was updated successfully, but these errors were encountered: