If a function throws an exception, any applicable 'freearg' typemaps are not executed and leaks may occur.
%typemap(in) Data*
{
$1 = new Data($input)
}
%typemap(freearg) Data*
{
delete $1;
}
class Data
{
// something
};
class Foo
{
public:
void Bar(Data* data) throw (Exception);
};
Seems to have been fixed since. With SWIG 4.0.2 and Python I get:
However ... PHP had issues. I've pushed a fix to git master which will be in SWIG 4.1.0.