Paul Knopf
2017-06-11 04:54:27 UTC
I originally posted this on GitHub, but there doesn't seem to be much
activity in the issues.
https://github.com/swig/swig/issues/998
In short, the code being generated by swig that invokes callbacks/delegates
in c++, to be passed to c#, is causing memory leaks.
This is the generated code.
NetMethodInfo const
*SwigDirector_NetInvokerBase::GetMethodInfo(std::string tt) {
NetMethodInfo *c_result = 0 ;
void * jresult = 0 ;
char * jtt ;
if (!swig_callbackGetMethodInfo) {
return NetInvokerBase::GetMethodInfo(tt);
} else {
jtt = SWIG_csharp_string_callback((&tt)->c_str());
jresult = (void *) swig_callbackGetMethodInfo(jtt);
c_result = (NetMethodInfo *)jresult;
}
return (NetMethodInfo const *)c_result;
}
This is the changed generated code that resolves this problem.
NetMethodInfo const
*SwigDirector_NetInvokerBase::GetMethodInfo(std::string tt) {
NetMethodInfo *c_result = 0 ;
void * jresult = 0 ;
char * jtt ;
if (!swig_callbackGetMethodInfo) {
return NetInvokerBase::GetMethodInfo(tt);
} else {
//jtt = SWIG_csharp_string_callback((&tt)->c_str());
jresult = (void *) swig_callbackGetMethodInfo((&tt)->c_str());
c_result = (NetMethodInfo *)jresult;
}
return (NetMethodInfo const *)c_result;
}
Anybody have any idea why this is happening? I am using swig 3.0
activity in the issues.
https://github.com/swig/swig/issues/998
In short, the code being generated by swig that invokes callbacks/delegates
in c++, to be passed to c#, is causing memory leaks.
This is the generated code.
NetMethodInfo const
*SwigDirector_NetInvokerBase::GetMethodInfo(std::string tt) {
NetMethodInfo *c_result = 0 ;
void * jresult = 0 ;
char * jtt ;
if (!swig_callbackGetMethodInfo) {
return NetInvokerBase::GetMethodInfo(tt);
} else {
jtt = SWIG_csharp_string_callback((&tt)->c_str());
jresult = (void *) swig_callbackGetMethodInfo(jtt);
c_result = (NetMethodInfo *)jresult;
}
return (NetMethodInfo const *)c_result;
}
This is the changed generated code that resolves this problem.
NetMethodInfo const
*SwigDirector_NetInvokerBase::GetMethodInfo(std::string tt) {
NetMethodInfo *c_result = 0 ;
void * jresult = 0 ;
char * jtt ;
if (!swig_callbackGetMethodInfo) {
return NetInvokerBase::GetMethodInfo(tt);
} else {
//jtt = SWIG_csharp_string_callback((&tt)->c_str());
jresult = (void *) swig_callbackGetMethodInfo((&tt)->c_str());
c_result = (NetMethodInfo *)jresult;
}
return (NetMethodInfo const *)c_result;
}
Anybody have any idea why this is happening? I am using swig 3.0