-
-
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
variables in closure iterators loop are not correctly unassigned #19193
Comments
I cannot prioritize this bug, as a workaround exists and IMHO in order to optimize memory consumption you should compile with --gc:orc and 1.6.0 and run the sanitizers, esp. valgrind on it. |
our issue is not so much in finding memory issues, that's not too hard :) This issue is about addressing the ones we do find that are systemic with the default GC - all this while we wait for ORC to work well enough that we reliably can use it. |
Example
will use a lot of memory, because the lines:
will generate:
which erases the last reference before calling
asgnRef
.Assigning directly avoids this issue:
var heavy = newSeq[int](10000)
Because the
heavy2 = 0
line is not generated, andasgnRef
will calldecRef
on the last value.Possible Solution
It seems that in regular procs, the var line will be translated to:
Since we assign to NIL instead of setting to 0 manually, the reference count is correctly updated
Additional Information
Happens both on 1.2.6 & devel.
Obviously, the mark & sweep will catch that, but as part of optimizing ram consumption in nimbus, we're trying to rely on it as little as possible
The text was updated successfully, but these errors were encountered: