Changeset 56625 in vbox for trunk/doc/manual
- Timestamp:
- Jun 24, 2015 5:18:45 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/SDKRef.xml
r56544 r56625 3840 3840 SDK. It contains exception handling and error printing code, which 3841 3841 is important for reliable larger scale projects.</para> 3842 3843 <para>It is good practice in long-running API clients to process the 3844 system events every now and then in the main thread (does not work 3845 in other threads). As a rule of thumb it makes sense to process them 3846 every few 100msec to every few seconds). This is done by 3847 calling<programlisting> 3848 mgr.waitForEvents(0); 3849 </programlisting> 3850 This avoids that a large number of system events accumulate, which can 3851 need a significant amount of memory, and as they also play a role in 3852 object cleanup it helps freeing additional memory in a timely manner 3853 which is used by the API implementation itself. Java's garbage collection 3854 approach already needs more memory due to the delayed freeing of memory 3855 used by no longer accessible objects, and not processing the system 3856 events exacerbates the memory usage. The 3857 <computeroutput>TestVBox.java</computeroutput> example code sprinkles 3858 such lines over the code to achieve the desired effect. In multi-threaded 3859 applications it can be called from the main thread periodically. 3860 Sometimes it's possible to use the non-zero timeout variant of the 3861 method, which then waits the specified number of milliseconds for 3862 events, processing them immediately as they arrive. It achieves better 3863 runtime behavior than separate sleeping/processing.</para> 3842 3864 </sect1> 3843 3865 </chapter>
Note:
See TracChangeset
for help on using the changeset viewer.