Removed lib/system/allocators.nim. seqs_v2 and strs_v2 now uses allocShared0. (#13190)
* Cleanup, remove lib/system/allocators.nim. seqs_v2 and strs_v2 now use allocShared0 by default. * Fixed -d:useMalloc allocShared / reallocShared / deallocShared. These now use the alloc/dealloc/realloc implementation that also takes care of zeroing memory at realloc. * Removed debug printfs * Removed unpairedEnvAllocs() from tests/destructor/tnewruntime_misc * More mmdisp cleanups. The shared allocators do not need to zero memory or throw since the regular ones already do that * Introduced realloc0 and reallocShared0, these procs are now used by strs_v2 and seqs_v2. This also allowed the -d:useMalloc allocator to drop the extra header with allocation length. * Moved strs_v2/seqs_v2 'allocated' flag into 'cap' field * Added 'getAllocStats()' to get low level alloc/dealloc counters. Enable with -d:allocStats * *allocShared implementations for boehm and go allocators now depend on the proper *allocImpl procs
This commit is contained in:
parent
f500895efe
commit
b68eb1cad0
21 changed files with 275 additions and 312 deletions
|
|
@ -1,17 +1,15 @@
|
|||
discard """
|
||||
cmd: '''nim cpp --newruntime --threads:on $file'''
|
||||
cmd: '''nim cpp -d:allocStats --newruntime --threads:on $file'''
|
||||
output: '''(field: "value")
|
||||
Indeed
|
||||
axc
|
||||
(v: 10)
|
||||
0 new: 0
|
||||
...
|
||||
destroying GenericObj[T] GenericObj[system.int]
|
||||
test
|
||||
'''
|
||||
(allocCount: 17, deallocCount: 15)'''
|
||||
"""
|
||||
|
||||
import system / allocators
|
||||
import system / ansi_c
|
||||
|
||||
import tables
|
||||
|
|
@ -24,6 +22,8 @@ type
|
|||
import os
|
||||
putEnv("HEAPTRASHING", "Indeed")
|
||||
|
||||
let s1 = getAllocStats()
|
||||
|
||||
proc main =
|
||||
var w = newTable[string, owned Node]()
|
||||
w["key"] = Node(field: "value")
|
||||
|
|
@ -87,9 +87,6 @@ proc testWrongAt() =
|
|||
|
||||
testWrongAt()
|
||||
|
||||
let (a, d) = allocCounters()
|
||||
discard cprintf("%ld new: %ld\n", a - unpairedEnvAllocs() - d, allocs)
|
||||
|
||||
#-------------------------------------------------
|
||||
type
|
||||
Table[A, B] = object
|
||||
|
|
@ -134,3 +131,4 @@ proc xx(xml: string): MyObject =
|
|||
|
||||
|
||||
discard xx("test")
|
||||
echo getAllocStats() - s1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue