```{index} single: destroy; Digest::MD5 function ``` ```{index} single: Digest::MD5::destroy; Perl function ``` # destroy Release the native MD5 state buffer when a context object is reaped. ## Synopsis ```perl ## Called automatically — you do not invoke DESTROY yourself. undef $ctx; # triggers DESTROY on the last reference ``` ## What you get back Nothing. `DESTROY` is Perl's object finaliser hook; it runs when the last reference to a `Digest::MD5` object goes away, frees the `MD5_CTX` buffer that was allocated alongside the object, and returns no value. You almost never call this directly. It is documented here so readers doing memory audits or writing subclasses know that the module owns a raw buffer behind the blessed reference and that the buffer is reclaimed on normal refcount-driven destruction. ## Examples Destruction happens when the last reference drops, either at scope exit or via explicit `undef`: ```perl { my $ctx = Digest::MD5->new; $ctx->add("data"); } # DESTROY runs here ``` Explicit drop mid-scope: ```perl my $ctx = Digest::MD5->new; $ctx->add("data"); undef $ctx; # DESTROY runs now, context is freed ``` ## Edge cases - Tolerant of malformed input: if the object does not carry the expected magic, `DESTROY` returns silently rather than croaking. This matches upstream and is important because `DESTROY` can be called during global destruction in arbitrary order. - Running on an already-destroyed context (possible during global destruction cycles) is a no-op. ## Differences from upstream Fully compatible with upstream `Digest::MD5` {{ upstream.Digest_MD5 }}. ## See also - `new` — the other end of the lifecycle - `clone` — each clone carries its own buffer and its own `DESTROY` - `reset` — avoid destruction entirely by reusing the context