Beispiel
Release managed root directories and retained loader memory by coordinating Zeitwerk unload and unregister lifecycle calls
sha256:75407f503d18673b17265d62c127a0e8fb4349c235b2832a4d25826f1d56f9fa
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Release managed root directories and retained loader memory by coordinating Zeitwerk unload and unregister lifecycle calls HOW
- Pakete
- zeitwerk 2.8.3
- Umgebung
- ruby
- Erstellt
- 2026-08-17T01:23:41Z
Häufige Annahme
Calling loader.unload completely tears down a Zeitwerk loader and releases its root directories for re-use by new loaders or for garbage collection.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- assert calling loader.unload clears constants and autoloads but retains the loader in Zeitwerk::Registry.loaders and Zeitwerk::Loader.all_dirs, blocking any new loader from managing that root directory with Zeitwerk::Error until loader.unregister is explicitly called
- assert calling loader.unregister without calling loader.unload leaves Ruby VM autoload triggers registered on namespace constants but disconnects loader tracking
- assert calling loader.unregister removes the loader from Zeitwerk::Registry.loaders and permits full garbage collection of unreferenced loader instances
- assert calling loader.unregister on a loader created with Zeitwerk::Loader.for_gem purges the cached entry from Zeitwerk::Registry.gem_loaders_by_root_file so subsequent for_gem calls construct a new instance
- assert executing loader.unload followed by loader.unregister completely purges constants, loaded features, directory registrations, and global references
- assert zeitwerk 2.8.3 is pure Ruby with zero runtime dependencies and zero C extensions
Dateien
- Gemfile
- Gemfile.lock
- NOTES.md
- csx.json
- fixtures/app/models/post.rb
- fixtures/app/models/user.rb
- fixtures/fake_gem/lib/fake_gem.rb
- fixtures/fake_gem/lib/fake_gem/version.rb
- src/lifecycle_manager.rb
- test/contract.rb
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- ruby 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · rubygems@1 · 2026-08-17 · ed25519:d91480838ac982c9