メモリ管理におけるオーナーシップとは何か?
オーナーシップはメモリ管理の規律であり、すべての値には、スコープを外れたときにそのリソースを解放する責任を持つ明確な所有者が一つ存在します。所有権はムーブによって移せますが複製はできないため、常にちょうど一つの所有者が存在します。この単一所有者の規則により、メモリがいつどこで解放されるかが明確になります。
なぜ重要か
明確なオーナーシップモデルにより、コンパイラはgarbage collectorなしで決定論的にメモリを解放でき、ダブルフリーを排除できます。これはムーブセマンティクスとボローチェックの概念的な支柱です。
関連ガイド
What Are Move Semantics?Move semantics transfer ownership of a resource from one object to another without copying, leaving the sourc…
What Is a Borrow Checker?A borrow checker is a compile-time analysis that enforces rules about references so a program cannot use memo…
What Is Reference Counting?Reference counting tracks how many references point to an object and frees it automatically when that count d…