Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Memory leak
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Programming issues== Memory leaks are a common error in programming, especially when using [[programming language|languages]] that have no built in automatic [[garbage collection (computer science)|garbage collection]], such as [[C (programming language)|C]] and [[C++]]. Typically, a memory leak occurs because [[Dynamic memory allocation|dynamically allocated]] memory has become [[Unreachable memory|unreachable]]. The prevalence of memory leak [[Software bug|bugs]] has led to the development of a number of [[debugging]] [[Programming tool|tool]]s to detect unreachable memory. ''[[BoundsChecker]]'', ''[[Deleaker]]'', Memory Validator, ''[[IBM Rational Purify]]'', ''[[Valgrind]]'', ''[[Parasoft]] [[Insure++]]'', ''[[DynamoRIO#Dr. Memory|Dr. Memory]]'' and ''[[memwatch]]'' are some of the more popular [[memory debugger]]s for C and C++ programs. "Conservative" garbage collection capabilities can be added to any programming language that lacks it as a built-in feature, and libraries for doing this are available for C and C++ programs. A conservative collector finds and reclaims most, but not all, unreachable memory. Although the [[Memory management|memory manager]] can recover unreachable memory, it cannot free memory that is still reachable and therefore potentially still useful. Modern memory managers therefore provide techniques for programmers to semantically mark memory with varying levels of usefulness, which correspond to varying levels of ''reachability''. The memory manager does not free an object that is strongly reachable. An object is strongly reachable if it is reachable either directly by a [[strong reference]] or indirectly by a chain of strong references. (A ''strong reference'' is a reference that, unlike a [[weak reference]], prevents an object from being garbage collected.) To prevent this, the developer is responsible for cleaning up references after use, typically by setting the reference to [[null pointer|null]] once it is no longer needed and, if necessary, by deregistering any [[event listener]]s that maintain strong references to the object. In general, automatic memory management is more robust and convenient for developers, as they do not need to implement freeing routines or worry about the sequence in which cleanup is performed or be concerned about whether or not an object is still referenced. It is easier for a programmer to know when a reference is no longer needed than to know when an object is no longer referenced. However, automatic memory management can impose a performance overhead, and it does not eliminate all of the programming errors that cause memory leaks.{{facts|date=February 2025}}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Memory leak
(section)
Add topic