You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found a memory leak when using system.find(). It seems to be caused by "return" keyword.
Example
typeFoo=refobjectofRootObj
data: int
children*: seq[Foo]
proc`=destroy`(self: vartype(Foo()[])) =echo"destroy foo ", self.data
for i in self.fields: i.reset
# Just a copy of system.find.procsystemFind[T, S](a: T, item: S): int {.inline.}=for i initems(a):
if i == item: returninc(result)
result=-1# Another version without "return" keyword.procmyFind[T, S](a: T, item: S): int {.inline.}=var found =falsefor i initems(a):
if i == item:
found =truebreakinc(result)
ifnot found:
result=-1var w1 =Foo(data: 1)
var w2 =Foo(data: 2)
var w3 =Foo(data: 3)
w1.children =@[w2, w3]
discard w1.children.systemFind(w3) # Has memory leak# discard w1.children.myFind(w3) # No memory leak
Current Output
destroy foo 1
destroy foo 2
Expected Output
destroy foo 1
destroy foo 2
destroy foo 3
$ nim -v
Nim Compiler Version 1.1.1 [Windows: amd64]
Compiled at 2020-03-11
The text was updated successfully, but these errors were encountered:
I found a memory leak when using system.find(). It seems to be caused by "return" keyword.
Example
Current Output
Expected Output
The text was updated successfully, but these errors were encountered: