From 0dac244647ef979381d05bb2781c564717519f10 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Tue, 26 Aug 2014 07:27:23 +0000 Subject: Re #1768: Add forced GC to libDestroy() in SWIG Java. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4906 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip-apps/src/swig/pjsua2.i | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pjsip-apps/src/swig/pjsua2.i b/pjsip-apps/src/swig/pjsua2.i index aff740b4..ae76bd51 100644 --- a/pjsip-apps/src/swig/pjsua2.i +++ b/pjsip-apps/src/swig/pjsua2.i @@ -102,7 +102,6 @@ using namespace pj; %template(CodecInfoVector) std::vector; %include "pjsua2/media.hpp" -%include "pjsua2/endpoint.hpp" %include "pjsua2/presence.hpp" %include "pjsua2/account.hpp" %include "pjsua2/call.hpp" @@ -112,3 +111,24 @@ using namespace pj; %ignore pj::JsonDocument::allocElement; %ignore pj::JsonDocument::getPool; %include "pjsua2/json.hpp" + +// Try force Java GC before destroying the lib: +// - to avoid late destroy of PJ objects by GC +// - to avoid destruction of PJ objects from a non-registered GC thread +#ifdef SWIGJAVA +%rename(libDestroy_) pj::Endpoint::libDestroy; +%typemap(javacode) pj::Endpoint %{ + public void libDestroy(long prmFlags) throws java.lang.Exception { + Runtime.getRuntime().gc(); + libDestroy_(prmFlags); + } + + public void libDestroy() throws java.lang.Exception { + Runtime.getRuntime().gc(); + libDestroy_(); + } +%} +#endif + +%include "pjsua2/endpoint.hpp" + -- cgit v1.2.3