On Thu, 2004-01-01 at 21:50, Marcus Holland-Moritz wrote:
> On 2004-01-01, at 20:16:27 +0000, [EMAIL PROTECTED] wrote:
> 
> > On Thu, Jan 01, 2004 at 09:10:28PM +0100, Marcus Holland-Moritz wrote:
> > | On 2004-01-01, at 19:09:51 +0000, [EMAIL PROTECTED] wrote:
> > | 
> First, don't pass NULL as RETVAL. This looks to me like you want to
> return an undefined value. Use XSRETURN_UNDEF instead.

True.
> 
> There's a memory leak and it has to do with reference counts.
> newAV() creates a new Perl array that initially has a reference
> count of 1. As you cannot return an "array", but only an array
> reference, xsubpp will take care of that and return an array
> reference for you. Unfortunately, it uses newRV_inc() for that
> purpose, which increments the reference count of the array.
> Thus, the reference count of the array is 2, but there's only
> one actual reference to the array. This way, the array will
> never be freed => memory leak.
> 
> I'm not sure if that should be considered a bug in xsubpp or not.
> I'll invesigate.
> 
> Until then, you should perhaps construct the array reference
> directly:

Thanks. These XS little bits make really the difference ;)
Now it is maintaining correctly the memory used.

Best regards,
Alberto

Reply via email to