On Jul 12, 2007, at 4:46 AM, Christian Hoermann wrote:

Now, the question is whether the following code would leak memory
(under mod_perl) or work as intended. In other words, if the sub calls
die (the intended effect), will the temporaries still get cleaned up
in a persistent environment such as mod_perl?

sv_2mortal() exists to ensure that things that go onto the stack are cleaned up if they are not otherwise stored.

As i understand it:

1.  Create a new sv with refcount 1.
2.  sv_2mortal() makes that refcount 0.
3.  Put it on the stack, no refcount change.
4.  call_sv(), stuff happens.  there's a die().
5. somewhere, either in the die() or after, perl will free everything on the orphaned stack, and your temps will be cleaned up.

Anyone with better internals knowledge than i (likely many on this list), please correct me.

--
It's all very complicated and would take a scientist to explain it.
  -- MST3K


Reply via email to