-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak for simple callback #174
Comments
Attaching a function does lock some data structures into memory, which does appear as a memory leak. There is a trade off between memory usage and the increased speed of using an attached XSUB. If I do not attach the same script and use a function object like this: my $mylib_func = $ffi->function( mylib_func => [ 'callback_t' ] => 'void' );
my $callback = $ffi->closure(
sub { say "Perl callback()" }
);
$mylib_func->call( $callback ); then I see only two leaks:
I think this has to do with the way it caches the basic types and global destruction. This could probably be improved, however. |
I think I might be able to improve the situation with attach too. |
I have this simple test library in C lib/mylib.c:
I compiled it with
Then I created a test Perl script p.pl:
and running the script seems to work fine:
Then I wanted to run it through
valgrind
to check that everything worked.First I created a debugging version of
perl
:Then I ran it with
valgrind
settingPERL_DESTRUCT_LEVEL=2
as recommended in perlhacktips:So it seems there are some memory leaks here? Any idea what the problem is?
The text was updated successfully, but these errors were encountered: