Marcus Holland-Moritz wrote: > On 2006-03-23, at 15:22:01 +0000, Alberto Manuel Brandão Simões wrote: > > >>Hi >> >>I am working with XS, and creating an array. It is basically something like: >> >> array = newAV(); >> av_push(array, newSVuv(dictionary_get_occ(D, wid))); >> >> for (j = 0; j < MAXENTRY; j++) { >> twid = 0; >> prob = 0.0; >> twid = dictionary_get_id(D, wid, j); >> if (twid) { >> prob = dictionary_get_val(D, wid, j); >> tword = word_list_get_by_id(T, twid); >> av_push(array, newSVpv(tword, strlen(tword))); >> av_push(array, newSVnv(prob)); >> } >> } >> RETVAL = newRV_noinc((SV*)array); >> >>The question is: the objects created here (newSVpv, newSVnv and the >>array) are freed in case they are no more used? > > > Yes. :-) > > When in doubt, it's usually a good idea to check the reference counts > with Devel::Peek:
also, inside the gdb debugger, SVs, AVs and HVs can be dumped with this command: call Perl_sv_dump(my_value) or on a threaded perl call Perl_sv_dump(Perl_get_context(), my_value) It's easy to set a breakpoint at the start of the XS subroutine (the real name appears on the .c file generated from the XS), and then single-step through the code. BTW, having a version of perl compiled with debugging support and with optimizations turned off also helps. Cheers, - Salva