Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 6. References > Item 63. Be careful with circular data structures

Item 63. Be careful with circular data structures

Perl currently uses a reference-counting approach to memory management. Each time an object acquires a name or a new reference, Perl increments that object’s reference count. Whenever an object loses a name or a reference, Perl decrements its reference count. Once an object’s reference count reaches zero, Perl deletes the object and reclaims the storage used by it.

Reference counting fails when objects point to one another in a circular or self-referential fashion. Consider the following example:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial