Changes between Version 17 and Version 18 of pjsip-doc/intro_pjsua2


Ignore:
Timestamp:
May 4, 2016 9:58:01 AM (4 years ago)
Author:
ming
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pjsip-doc/intro_pjsua2

    v17 v18  
    6161Garbage collection (GC) exists in Java and Python (and other languages, but we don't support those for now), and there are some problems with it when it comes to PJSUA2 usage: 
    6262 
    63 - it delays the destruction of objects (including PJSUA2 objects), causing the code in object's destructor to be executed out of order 
    64 - the GC operation may run on different thread not previously registered to PJLIB, causing assertion 
    65  
    66 Due to problems above, application '''MUST immediately destroy PJSUA2 objects using object's delete() method (in Java)''', instead of relying on the GC to clean up the object. 
    67  
     63 1. premature destruction of PJSUA2 objects which are created in Java and Python space and passed to the native space 
     64 2. it delays the destruction of objects (including PJSUA2 objects), causing the code in object's destructor to be executed out of order 
     65 3. the GC operation may run on different thread not previously registered to PJLIB, causing assertion 
     66 
     67Some examples for problem 1 are (these examples are by no means a complete list) when adding Buddy object to an account using Account.addBuddy() or setting LogWriter by calling EpConfig.LogConfig.setLogWriter(). To avoid this problem, application needs to maintain an explicit reference on objects created in its application, instead of relying on PJSUA2 native library to keep track of those objects, i.e. : 
     68 
     69.. code-block:: c++ 
     70 
     71    class MyApp { 
     72        private MyLogWriter logWriter; 
     73    
     74        public void init() 
     75        { 
     76            /* Maintain reference to log writer to avoid premature cleanup by GC */ 
     77            logWriter = new MyLogWriter(); 
     78            epConfig.getLogConfig.setWriter(logWriter); 
     79        } 
     80    } 
     81 
     82While for problems 2 and 3, application '''MUST immediately destroy PJSUA2 objects using object's delete() method (in Java)''', instead of relying on the GC to clean up the object. 
    6883For example, to delete an Account, it's **NOT** enough to just let it go out of scope. Application MUST delete it manually like this (in Java): 
    6984