Memory leak with Inline::C

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I'm seeing a memory leak with the Inline code below.  The sub by_inline()
returns a varying number of scalars, which is probably the crux of the

The code works as expected (returning the exponents of 2 used in the
binary representation of the argument), but the loop leaks.  It leaks
just the same when by_inline() is called in void context.

I don't see anything obviously wrong with the code, in particular the
newly created SVs are carefully mortalized, but I'd like a second opinion.

I'd also be grateful if one or the other could find the time to run
the code and report back.  For me, the process grows to 500+ MB before
the loop runs out (I kill it when swapping becomes audible).

Conditions here:
Darwin 7.4.0, Perl 5.8.4, Inline 0.44, gcc 3.3


use strict; use warnings; $| = 1;
use Vi::QuickFix;

my @res = by_inline( int rand 2 ** 32) for 1 .. 100_000;

use Inline C => <<EOC;
void by_inline( int x) {
    int i;
    i = 0;
    while ( x ) {
        if ( x & 1 ) {
            Inline_Stack_Push( sv_2mortal( newSViv( i)));
        x >>= 1;
        i ++;

Site Timeline