3 ms·
There are (at least) 2 definitions of memory leak. The upsides of the definition you gave are that it's simple, well defined, and maximally precise (nothing th
by cobbal 2y ago
There are (at least) 2 definitions of memory leak.
The upsides of the definition you gave are that it's simple, well defined, and maximally precise (nothing that is safe to collect is considered live)
The significant downside to this definition is that it's uncomputable. To know if memory is used requires knowing if a loop halts.
The second definition of memory leak is "unreachability" which is a bit harder to nail down. It's a conservative approximation of the first definition, but is more popular because it's computable, and it's practical to write programs with or without GC that don't leak
- loeg 2y agoThe latter definition is not particularly useful for writing programs that run on hardware with finite memory. End users don't care whether or not the allocations are reachable when your program uses all the memory in the system and crowds out other programs, slows, and/or crashes.