in reply to Perl XS: garbage-collecting my malloc'd buffer

What I usually do when I have questions like this is to examine the C source that gets generated from your XS file to make sure it all looks ok.

As a side note, when I think of GC, I think of variables/objects tracked via reference counts, where their memory is free'd automatically by perl when their reference counts reach zero (usually from being destroyed or going out of scope). In your case, you are defining a function, not a variable, and are explicitly free()ing the buffer yourself when its no longer needed, so this isn't really garbage collection.

  • Comment on Re: Perl XS: garbage-collecting my malloc'd buffer