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

This commit is contained in:
Araq
2014-02-07 17:06:20 +01:00
parent 3be07d842a
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)
tmp2.k = locTemp
tmp2.t = field.loc.t
tmp2.s = OnHeap
tmp2.s = if isRef: OnHeap else: OnStack
tmp2.heapRoot = tmp.r
expr(p, it.sons[1], tmp2)
if d.k == locNone:

View File

@@ -2231,6 +2231,8 @@ Instead of:
Using statement
---------------
**Warning**: The ``using`` statement is highly experimental!
The `using statement`:idx: provides syntactic convenience for procs that
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

View File

@@ -6,7 +6,7 @@ when defined(GC_setMaxPause):
GC_setMaxPause 2_000
type
TExpr = object ## abstract base class for an expression
TExpr = object {.inheritable.} ## abstract base class for an expression
PLiteral = ref TLiteral
TLiteral = object of TExpr
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 "gctest"
test "gcleak3"
test "gcleak4"
test "gcleak5"
test "weakrefs"
test "cycleleak"
test "closureleak"
test "refarrayleak"
rest "stackrefleak"
# ------------------------- threading tests -----------------------------------

View File

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