3 ms·
> just never calling free() So your code would look a lot like it was running under a garbage collector? The OS memory manager is the garbage collector in this
by zamalek 8y ago
> just never calling free()
So your code would look a lot like it was running under a garbage collector? The OS memory manager is the garbage collector in this case.
- ecnahc515 8y agoNo, because the OS isn't reclaiming the memory specifically; and this only works with overcommit and/or swap. The memory isn't actually being reclaimed, it's being paged out. If your application actually begins to use the memory but never uses the data again (eg; can't reference it) it will continue to eat memory until the OOM killer kicks in or the system crashes.
- eximius 8y agoWell, unless your program is particularly long lived, it will be reclaimed. There are many tools that could reasonably forego `free` for their entire runtimes.
- ecnahc515 8y agoI presume we're talking about long running programs otherwise the conversation isn't really super useful since for any program, short or long memory is reclaimed when a program exits (well, at least on any modern OS).