Smart pointer

from Wikipedia, the free encyclopedia

Intelligent pointers or smart pointers are used in many common programming languages such as C ++ . These are special pointers that have additional functions and properties compared to simple pointer variables. Intelligent pointers thus extend simple pointers and provide them with more functionality, but can be used like normal pointer variables.


In order to avoid accidentally releasing memory areas that are still referenced by one or the other pointers, reference-counting pointers are used. To do this, the intelligent pointer contains a counter variable that is incremented each time the pointer is copied. If a part of the program tries to release the memory to which the pointer refers, the value of the counter variable is first reduced. The memory is only released when the counter reaches the value 0 (→ reference counting ) .


There are programming languages such as Oberon , Java or C # and runtime systems such as BlackBox Component Builder , Java Runtime Environment (JRE) or .NET , in which the referenced memory areas of all pointer variables are "intelligent" and managed exclusively by automatic garbage collection become.

Web links