mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-25 08:43:58 +00:00
bugfix: codegen issue that caused getGMTime() to leak memory
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
25
tests/gc/gcleak5.nim
Normal 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()
|
||||
@@ -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 -----------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user