Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Re: How I want my memory managed

by MarkM (Curate)
on Dec 13, 2002 at 07:04 UTC ( #219524=note: print w/replies, xml ) Need Help??

in reply to Re: How I want my memory managed
in thread How I want my memory managed

GC does not necessarily provide automatic circular reference breaking.

I prefer GC over reference counting because it simplifies implementation. A simpler implementation contains fewer bugs (on average). One improperly accounted reference can bring Perl down with a core dump, or worse.

Replies are listed 'Best First'.
Re^3: How I want my memory managed
by Aristotle (Chancellor) on Dec 14, 2002 at 23:02 UTC
    You prefer a garbage collector over reference counting..?

    Makeshifts last the longest.

      I prefer systems that do not require regular explicit house cleaning in every piece of code that accesses shared data structures. Garbage collection is one means of reducing the explicit house cleaning. Count how many times SvREFCNT_inc() and SvREFCNT_dec() appear in the Perl source code, and figure on the possibility that any of these might be invoked at the wrong time, or not enough times. At this point, I am not even considering performance, or storage. The basic principle is that a less complicated system will probably have less potential to include bugs.

      For other examples of the potential for bugs in schemes that rely on explicit house cleaning, such as reference counting, consider the delivery of signals, or the trapping of exceptions. Perl implements an interesting work-around to this problem called 'mortal scalars'. The caller maintains a set of scalars that need to be dereferenced during an unwind operation. Most code, however, creates the scalar first, and then marks it 'mortal' leaving a small window for memory to be leaked.

      Issues such as performance are a little less black and white. Anybody can write an inefficient reference counting scheme, or an inefficient garbage collection scheme. For example, earlier versions of Perl used to use a MUTEX lock around all SvREFCNT_inc() and SvREFCNT_dec() operations in the 'thread-safe' version of the code. This is horribly expensive. It is a lot more efficient to implement reference counting using native assembly code, at least for common platforms, as operations like SvREFCNT_dec() can usually be implemented to be as cheap as a standard decrement instruction followed by a test instruction, without the need for thread synchronization.

      Reference counting has benefits. As a preference, though, I could live without these benefits, if it improved my level of comfort in the code base.

        I know all that. :) My point is that reference counting is a technique of garbage collection.. so you got your terminology mixed up. What you meant to say is mark&sweep vs refcounting.

        Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://219524]
[stevieb]: ahhh you're talking about the actual Makefile, not the PP Makefile.PL
[Corion]: LanX: But most of that is just setup of variables to be used later, like CC , LIB etc.
[LanX]: yes and some builders try to avoid it
[RonW]: :)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2017-08-18 21:06 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (310 votes). Check out past polls.