summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-02-12 08:28:46 +0100
committerAraq <rumpf_a@web.de>2013-02-12 08:28:46 +0100
commit5e7dd69b000f762ce3659e5c615a648ede44bb52 (patch)
treee8797cffba467d3a85b1261b59b2ce9da9c8114f /lib/system
parent68135b3b500074b43bf155a4a8cbb77756f112d2 (diff)
downloadNim-5e7dd69b000f762ce3659e5c615a648ede44bb52.tar.gz
GC: incRef needs to add cycleroots
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/gc.nim10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim
index bd8c7a5da..33b82686f 100644
--- a/lib/system/gc.nim
+++ b/lib/system/gc.nim
@@ -18,9 +18,6 @@
 # for soft real time applications (like games).
 {.push profiler:off.}
 
-# XXX there is still a slight chance of leaking cycles as we don't add cycle
-# candidates in 'incRef'
-
 const
   CycleIncrease = 2 # is a multiplicative increase
   InitialCycleThreshold = 4*1024*1024 # X MB because cycle checking is slow
@@ -201,10 +198,11 @@ proc decRef(c: PCell) {.inline.} =
 
 proc incRef(c: PCell) {.inline.} = 
   gcAssert(isAllocatedPtr(gch.region, c), "incRef: interiorPtr")
-  c.refcount = c.refCount +% rcIncrement and not colorMask
+  c.refcount = c.refCount +% rcIncrement
+  # and not colorMask
   #writeCell("incRef", c)
-  #if canBeCycleRoot(c):
-  #  rtlAddCycleRoot(c)
+  if canBeCycleRoot(c):
+    rtlAddCycleRoot(c)
 
 proc nimGCref(p: pointer) {.compilerProc, inline.} = incRef(usrToCell(p))
 proc nimGCunref(p: pointer) {.compilerProc, inline.} = decRef(usrToCell(p))