bugfix: codegen issue that caused getGMTime() to leak memory

This commit is contained in:
Araq 2014-02-07 17:06:20 +01:00
commit a087f6057e
6 changed files with 35 additions and 3 deletions

View file

@ -1049,7 +1049,7 @@ proc genObjConstr(p: BProc, e: PNode, d: var TLoc) =
app(tmp2.r, field.loc.r) app(tmp2.r, field.loc.r)
tmp2.k = locTemp tmp2.k = locTemp
tmp2.t = field.loc.t tmp2.t = field.loc.t
tmp2.s = OnHeap tmp2.s = if isRef: OnHeap else: OnStack
tmp2.heapRoot = tmp.r tmp2.heapRoot = tmp.r
expr(p, it.sons[1], tmp2) expr(p, it.sons[1], tmp2)
if d.k == locNone: if d.k == locNone:

View file

@ -2231,6 +2231,8 @@ Instead of:
Using statement Using statement
--------------- ---------------
**Warning**: The ``using`` statement is highly experimental!
The `using statement`:idx: provides syntactic convenience for procs that The `using statement`:idx: provides syntactic convenience for procs that
heavily use a single contextual parameter. When applied to a variable or a heavily use a single contextual parameter. When applied to a variable or a
constant, it will instruct Nimrod to automatically consider the used symbol as constant, it will instruct Nimrod to automatically consider the used symbol as

View file

@ -6,7 +6,7 @@ when defined(GC_setMaxPause):
GC_setMaxPause 2_000 GC_setMaxPause 2_000
type type
TExpr = object ## abstract base class for an expression TExpr = object {.inheritable.} ## abstract base class for an expression
PLiteral = ref TLiteral PLiteral = ref TLiteral
TLiteral = object of TExpr TLiteral = object of TExpr
x: int x: int

25
tests/gc/gcleak5.nim Normal file
View file

@ -0,0 +1,25 @@
discard """
output: "success"
"""
import os, times
proc main =
var i = 0
for ii in 0..50_000:
#while true:
var t = getTime()
var g = t.getGMTime()
#echo isOnStack(addr g)
if i mod 100 == 0:
let om = getOccupiedMem()
echo "memory: ", om
if om > 100_000: quit "leak"
inc(i)
sleep(1)
echo "success"
main()

View file

@ -123,9 +123,14 @@ proc gcTests(r: var TResults, cat: Category, options: string) =
test "gcleak2" test "gcleak2"
test "gctest" test "gctest"
test "gcleak3" test "gcleak3"
test "gcleak4"
test "gcleak5"
test "weakrefs" test "weakrefs"
test "cycleleak" test "cycleleak"
test "closureleak" test "closureleak"
test "refarrayleak"
rest "stackrefleak"
# ------------------------- threading tests ----------------------------------- # ------------------------- threading tests -----------------------------------

View file

@ -5,7 +5,7 @@ version 0.9.4
- fix macros\tstringinterp.nim - fix macros\tstringinterp.nim
- test and fix showoff - test and fix showoff
- test C source code generation - test C source code generation
- test and fix closures - fix closures
- test and fix exception handling - test and fix exception handling
- implement 'union' and 'bits' pragmas - implement 'union' and 'bits' pragmas