Nim wechselt zu effizienteren Speicherverwaltungsmodellen: ARC und ORC. Lassen Sie uns genau herausfinden, wie sie die Funktionsweise des Speichers ändern.

EinfĂźhrung
Hallo! In diesem Artikel werde ich versuchen zu erklären, was ARC und ORC sind und wie sie sich auf die Leistung oder andere Teile von Nim auswirken. Ich werde nicht tief in die Aspekte des Software-Teils eintauchen, aber ich werde versuchen, eine mehr oder weniger allgemeine Erklärung zu geben.
GC Nim refc ( mark & sweep ), , markAndSweep, boehm, go, regions.
Nim' , , (owned ref) :
, Nim ARC
ARC?
ARC , (Automatic Reference Counting) (move semantics). , ARC Nim , ARC Swift, â Nim ARC .
. ( runtime) , . , .
ARC GC Nim , ARC â (, , , .), . ARC C++ (RAII)
, , ARC expandArc, Nim 1.4.
Nim:
proc main =
let mystr = stdin.readLine()
case mystr
of "":
echo "!"
of "":
echo "!"
quit()
else:
discard
main()
nim c --gc:arc --expandArc:main example.nim.
--expandArc: main
var mystr
try:
mystr = readLine(stdin)
case mystr
of "":
echo ["!"]
of "":
echo ["!"]
quit(0)
else:
discard
finally:
`=destroy`(mystr)
-- end of expandArc ------------------------
â Nim main try: finally ( finally , try ) =destroy mystr, .
ARC: (scope-based MM). â . , , , . Nim' : , , , , block, for while .
ARC hooks â , , // . , , , FFI.
refc ARC ( ):
( ) â .
â , .
â
refc, (thread-local heap), ARC . â . RFC , ARC.
FFI â ,
refc"" (.. ) , ARC. , ARC , (.dll, .so, Python' )
-
(copy elision), Nim (cursor inference) â ()
, ARC Nim , , , .
, ARC , , , --gc:arc, (.nims .cfg).
! - ? ARC , , , . â , , . : 3 (A, B, C), , :

, , â , , .
Nim' mark & sweep refc GC, ARC - . :
ORC â Nim
ORC , ARC. GC, (local tracing phase) GC, (global tracing).
async Nim ORC, Nim' , .
ORC ARC () â ORC , hard realtime ( ) â .
ORC --gc:orc, , ORC GC Nim'
! ?
â â Nim 1.4. .
! â , !
/ :
- Introducing --gc:arc
- Update on --gc:arc
- New garbage collector --gc:orc is a joy to use.
- Offizielle Dokumentation zu Destruktoren und Verschiebungssemantik
- FOSDEM 2020 - Verschieben Sie die Semantik fĂźr Nim
- NimConf 2020 - Nim ARC / ORC
- Nim Gemeinschaft
- RFC: Kombinieren Sie GC / Memory Management-Optionen in Nim