code cleanup for mark&sweep GC
This commit is contained in:
parent
ab6f793408
commit
4ee9816a78
7 changed files with 43 additions and 88 deletions
|
|
@ -12,7 +12,9 @@ type
|
|||
proc MakeObj(): TTestObj =
|
||||
result.x = "Hello"
|
||||
|
||||
for i in 1 .. 100_000_000:
|
||||
for i in 1 .. 1_000_000:
|
||||
when defined(gcMarkAndSweep):
|
||||
GC_fullcollect()
|
||||
var obj = MakeObj()
|
||||
if getOccupiedMem() > 300_000: quit("still a leak!")
|
||||
# echo GC_getstatistics()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ proc MakeObj(): TTestObj =
|
|||
result.s = @[1,2,3]
|
||||
|
||||
proc inProc() =
|
||||
for i in 1 .. 100_000_000:
|
||||
for i in 1 .. 1_000_000:
|
||||
when defined(gcMarkAndSweep):
|
||||
GC_fullcollect()
|
||||
var obj: TTestObj
|
||||
obj = MakeObj()
|
||||
if getOccupiedMem() > 300_000: quit("still a leak!")
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ proc main =
|
|||
for i in 0 .. s.high:
|
||||
s[i] = register(create())
|
||||
# test that we have at least 80% unreachable weak objects by now:
|
||||
when defined(gcMarkAndSweep):
|
||||
GC_fullcollect()
|
||||
var unreachable = 0
|
||||
for i in 0 .. s.high:
|
||||
if access(s[i]) == nil: inc unreachable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue