On Sun, Sep 06, 2009 at 09:30:04PM +0100, Patrick Dupre wrote: > Hello, Hello,
> When I do: > XPUSHs (sv_2mortal (newRV_inc ((SV*) E_rot_up)) ; > Do I need to free the memory ? > I use the XPUSHs to pass an array of real to a perl sub, but I am > not sure that after the call, this memory sapce is freed. > Can I desallocate the memory space manually ? That will probably depend on how you allocated your array of reals in the first place. Since this is not an internal perl type you will probably have to use the deallocation routine corresponding to the allocation routine you used. But be sure you don't do this before perl has decided it is no longer going to use that array. > I tried to use valgrind to check my memort allocation, but it does not > give me much information ! Do you know a tools to check the memory > allocation when perl call C and vice versa ? Valgrind is a fine choice, though the problem is usually too much information. There is a section on using valgrind in perlhack. You will probably find it useful to set $PERL_DESTRUCT_LEVEL to 2 before running valgrind. There is also a section on this in perlhack. Personally, I don't consider this to be off topic for this list but it's probably true that there aren't many people here who are familiar with XS. You may find it helpful to post to perl...@perl.org in the future, assuming people there don't ignore you for asking such beginners' questions ;-) -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/