My guess is that you are failing to mortalise the SV which you are populating with the inbound data. If you posted the code, it would probably be the work of a few minutes to confirm that or otherwise track the leak down.
The code is too substantial to post, but maybe there is something I have wrong WRT to mortality.
My understanding is that that since $test has a reference count of 1, and the SV inside it has a reference count of 1, that $test=undef should free the memory used. Running that in a while(1) loop seems to confirm this -- there is no growth. Where in this code do you see an issue? Everything else follows the same pattern (I am not using the inline stack).#!/usr/bin/perl use strict; use warnings FATAL => qw(all); use Inline 'C'; my $test = eg(); reportHash($test); reportScalar($test->{x}); $test = undef; __DATA__ __C__ SV *eg () { HV *rv = newHV(); hv_store(rv, "x", 1, newSVpv("hello", 0), 0); return newRV_noinc((SV*)rv); } void reportHash (SV *ref) { HV *hash = (HV*)SvRV(ref); fprintf(stderr,"rc: %d\n", SvREFCNT((SV*)hash)); } void reportScalar (SV *s) { fprintf(stderr,"rc: %d\n", SvREFCNT(s)); }
In reply to Re^2: Tracing memory leak
by halfcountplus
in thread Tracing memory leak
by halfcountplus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |