You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following code (continuing my libpostal saga):
$ffi->attach(
[ libpostal_get_default_options=>'expansion_defaults' ],
[], 'expansion_options', );
$ffi->attach(
[ libpostal_expansion_array_destroy=>'destroy_expansions' ],
[ opaque=>'size_t' ]);
subprocess_char_pp {
my ($inner, @args) = @_;
#call the functionmy$ret_ptr =
$inner->(@args, \my$ret_len);
#nothing to do if there are no resultsreturn () unless$ret_len;
#cast the char** into an arrayrefmy$ret = $ffi->cast( opaque=>"string[$ret_len]", $ret_ptr);
#clean up the C side of things
destroy_expansions($ret_ptr, $ret_len);
#send back the string[]return@$ret;
}
subprocess_expansions {
#third arg is the options, if not passed, then supply the#defaults$_[2] //= expansion_defaults();
process_char_pp(@_);
}
$ffi->attach(
[ libpostal_expand_address=>'expand_address' ],
[ 'string', 'expansion_options', 'size_t*' ],
'opaque', \&process_expansions );
The problem I'm having is that none of the things returned from Platypus is ever getting freed. I did a simple test with Test::LeakTrace and it shows that the options struct leaks, as does the arrayref containing the returned strings and the strings themselves. (I also did a overview test, where I ran the function a million times, and continually ate up more and more memory).
Am I missing something? Where is the extra reference to each of these items?
Yeah, it is! From looking at my tests in Geo::Postal::FFI, the only 'leaks' are things that Platypus is caching. Thank you so much for your tireless work!
I have the following code (continuing my libpostal saga):
The problem I'm having is that none of the things returned from Platypus is ever getting freed. I did a simple test with
Test::LeakTrace
and it shows that the options struct leaks, as does the arrayref containing the returned strings and the strings themselves. (I also did a overview test, where I ran the function a million times, and continually ate up more and more memory).Am I missing something? Where is the extra reference to each of these items?
The full code and the test file 't/03-valgrind.t' are in my repo at https://github.com/rabbiveesh/FFI-Postal
The text was updated successfully, but these errors were encountered: