diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim index 5b67a10ac..911f3e566 100755 --- a/compiler/nimrod.nim +++ b/compiler/nimrod.nim @@ -72,7 +72,7 @@ proc HandleCmdLine() = when defined(GC_setMaxPause): GC_setMaxPause 2_000 -when compileOption("gc", "v2"): +when compileOption("gc", "v2") or compileOption("gc", "refc"): # the new correct mark&sweet collector is too slow :-/ GC_disableMarkAndSweep() condsyms.InitDefines() diff --git a/doc/manual.txt b/doc/manual.txt index 1ac241b06..ad43d0379 100755 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -911,7 +911,21 @@ Arrays are always bounds checked (at compile-time or at runtime). These checks can be disabled via pragmas or invoking the compiler with the ``--boundChecks:off`` command line switch. -The current implementation does not support nested open arrays. + +Open arrays +----------- + +Often fixed size arrays turn out to be too inflexible; procedures should +be able to deal with arrays of different sizes. The `openarray`:idx: type +allows this; it can only be used for parameters. Openarrays are always +indexed with an ``int`` starting at position 0. The ``len``, ``low`` +and ``high`` operations are available for open arrays too. Any array with +a compatible base type can be passed to an openarray parameter, the index +type does not matter. In addition to arrays sequences can also be passed +to an open array parameter. + +The openarray type cannot be nested: multidimensional openarrays are not +supported because this is seldom needed and cannot be done efficiently. Varargs diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 538748b15..bd8c7a5da 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -18,6 +18,9 @@ # 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 @@ -33,7 +36,6 @@ when defined(memProfiler): const rcIncrement = 0b1000 # so that lowest 3 bits are not touched - # NOTE: Most colors are currently unused rcBlack = 0b000 # cell is colored black; in use or free rcGray = 0b001 # possible member of a cycle rcWhite = 0b010 # member of a garbage cycle diff --git a/tests/gc/cycleleak.nim b/tests/gc/cycleleak.nim index 0153d0f72..9f5c30ebd 100644 --- a/tests/gc/cycleleak.nim +++ b/tests/gc/cycleleak.nim @@ -5,37 +5,51 @@ discard """ type Module = object nodes*: seq[PNode] + id: int PModule = ref Module Node = object owner*: PModule data*: array[0..200, char] # some fat to drain memory faster + id: int PNode = ref Node +var + gid: int + +when false: + proc finalizeNode(x: PNode) = + echo "node id: ", x.id + proc finalizeModule(x: PModule) = + echo "module id: ", x.id + proc newNode(owner: PModule): PNode = new(result) result.owner = owner + inc gid + result.id = gid proc compileModule: PModule = new(result) result.nodes = @[] for i in 0..100: result.nodes.add newNode(result) + inc gid + result.id = gid var gModuleCache: PModule proc loop = - for i in 0..10000: + for i in 0..1000: gModuleCache = compileModule() gModuleCache = nil GC_fullCollect() - if getOccupiedMem() > 900_000: + if getOccupiedMem() > 9_000_000: echo "still a leak! ", getOccupiedMem() quit(1) - echo "no leak: ", getOccupiedMem() loop() diff --git a/todo.txt b/todo.txt index 972a61f4e..a6ae409bd 100755 --- a/todo.txt +++ b/todo.txt @@ -4,6 +4,8 @@ version 0.9.2 - implement constructors + full 'not nil' checking - ``restrict`` pragma + backend support - fix: 'result' is not properly cleaned for NRVO +- document NimMain and check whether it works for threading + version 0.9.4 =============