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 | |
| 67 | Some 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 | |
| 82 | While 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. |