referenciaszámlálója
A referenciaszámlálója, commonly known as a reference counter, is a programming technique used for automatic memory management. It works by keeping track of how many references point to a particular object or resource. When an object is created, its reference count is initialized to one. Every time a new reference is made to that object, its count is incremented. Conversely, when a reference to an object is removed or goes out of scope, its count is decremented. When the reference count of an object reaches zero, it signifies that no part of the program is currently using that object, and therefore, its memory can be safely deallocated.
This method is a form of automatic memory management, aiming to prevent memory leaks and dangling pointers.
While effective, reference counting has some limitations. Circular references are a common problem. This occurs when