Linux and memory leaks -


does linux automatically re-claim memory used applications immediately?

if should application bother freeing memory before exit?

is worth call destructor of every class in multi-threading application before making call exit(0)?

if linux re-claims memory used application immediately, memory leaks dangling pointers application has created , lifetime.

does linux automatically re-claim memory used applications immediately?

no, yes in sense you're implying. virtual memory belonging process released. frames aren't shared made available other processes.

if should application bother freeing memory before exit?

yes, several reasons:

  • you may decide extend code toward other purposes in future, adding clean-up later on may difficult.
  • you have excessive memory usage, , need virtual memory space being "wasted".
  • you need track down bugs: not releasing resources acquired make debugging difficult.

there situations arise when not freeing memory want, these performance related, , specific situations.

is worth call destructor of every class in multi-threading application before making call exit(0)?

this pretty same last question. note not releasing resources third party, , os libraries same not freeing memory.

if linux re-claims memory used application immediately, memory leaks dangling pointers application has created , lifetime.

yup. time theory breaks down when resources held global, , don't go away @ process termination. shared memory, poorly designed third party libraries, temporary files etc. examples of these.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -