Home   Easy-Code    Forum  Updater 
Twitter Facebook

Java Note 2

Critics Rating:

Users Rating:

1.   Survivor Space
-   -XX:SurvivorRatio=8 – means, young generation is divided into 8 + 2 equalsections, and two of which are being used by the survivor spaces
•   If survivor space is small, the object gets promoted to old generation
•   If survivor space is too huge, the space is un-utilized
•   The size of the survivor spaces must be dictated/guided by the number of objects
-   alive after the couple of minor collections.
•   What we normally do is to take the size of survivor space 1 around 10 - 15% more
-   than the size indicated by the application minor log
•   For normal enterprise application survivor ratio should be around 50-60 (5gb
-   heap, 3gb should be for young generation)
2.   System.gc()
-   Never call system.gc() except for these few exceptions
•   Well defined application phased transaction
•   When the load is not too much (some time in the night)
•   When the application is effecting memory mapping through NIO
•   To clean up time critical native resources, how ever downsize must be kept in mind (full gc would happen) and better alternatives available thru reference objects
•   In j2ee application, system.gc is never required
•   A class gets unloaded when the class loader of that class gets unloaded and the
3.   class loader gets unloaded when all the classes that are loaded are not reachable.
-   Noclassgc – the perm space where the classes are stored, no gc would happen, no
4.   classes would be unloaded. (perm space should be large enough to accommodate
5.   all the required classes) (symptoms – lots of minor, major gc would happen
6.   recursively)
-   useparnewgc – for near and real time exception
-   useparlledgc – great for throughput
-   useParNewGC goes well for concurrent mark and sweep gc for low pause
7.   application. Parnewgc works exactly like copy collector except it many
8.   processors that are available. This is also settable.
-   UseParallelGC –
9.   First tuning option to try for through put application is userparllelGC with
10.   useadaptivesizepolicy
11.   Java –server –Xms3072m –XX:+UserParallelGC –
12.   XX:+UseAdaptiveSizePolicy
-   Heap is less – then fragmentation. If heap is huge, then gc would take lots of time,
13.   because has to visit the entire heap
14.   Using ISMs and Variable Page Sizes to overcome locality problems
15.   TLB – Translation look aside buffering –
16.   ISM – Intimate Shared Memory - increases GC - only for Solaris
17.   -XX:+UseISM option – this is applicable for Solaris and Linux. Changes need to made to /etc/system file to include the following parameters if more than 12GB of memory then increase the size of page. We can use UseISM which makes GC faster. There is a flip side to it. It blocks 256mb of memory.
18.   Threads needs to be taken care of; if threads increase beyond certain limit the performance comes degrades.
-   IO from OS is done in pages
-   IO, NW data is brought into the memory in-terms of pages not in bytes
-   GCTimeRatio should be used with adaptivesizepolicy and parallelgc – for throughput kind of applications (enterprise applications like finacle, j2ee, webbased)
-   Pausetime should be used with adaptivesizepolicy and parallelgc – for real and near real time of applications (fridge, embedded systems)
19.   This must be used
-   -XX:+UseBiasedLocking – removes un-contended synchronization
-   -XX:+UseAggresiveOpts – uses the JVM new options
•   Dynamic compiled methods will be stored in JVM native memory in Heap
•   -XX: +PrintCompilation – client – for printing the methods while compiling
•   -client
•   -server
•   XX:LargepageSizeInBytes=256m – on windows, OS changes needs to be done
20.   Finalization
one exception when it is recommended to make the reference null is when the object extends finalizable object and has extra variables that are collected before the 2nd cycle of GC
21.   Reference Object
-   these objects are garbage collectors way of feeding back information to the applications about gc
22.   Weak Reference
-   In a weak hashmap, the key is weakly reachable but not the value. When the key (referent) gets collected the gc adds the weak reference of this key (entity extends weakhashmap). Weakhashmap maintains a reference queue.
-   Weak references and phantom references are eagerly collected so do not use them for cache
23.   Soft Reference
-   Soft references are used for caching
24.   Phantom Reference
25.   Read Committed
-   Read committed is exactly like volatile
-   It does not offer exclusive access
-   Should be used for reading or inserting nor for modification
-   Gets the lock, doesn’t locks as the transaction goes, last updates and check sum problems can occur
26.   Repeatable Read
-   it’s just like synchronization
-   get the lock and holds it till transaction ends
-   checksum problems can occur and but not last update problems prevented
27.   Read Serializable
-   Not just individual record but entire table gets locked
-   Check sum problem resolved
28.   Read Uncommitted
-   dirty reads are possible
-   used only when the data is read only
-   is never updated
29.   Repeatable read
-   is advisable for financial transaction
30.   Read committed is basic level for optimistic locks
-   Collection is extended by List and Set
-   Collection returns an Iterator, remove method is present and add method is not present.
-   Set is un-ordered and list is ordered (the way it is entered)
31.   I/O
-   NIO (Network IO) uses many techniques which are supported by the current hardware
•   Memory Mapping – means data is brought out in-terms of pages instead of buffers
•   Scatter Gather (Vectored IO) – reduces the transfer time to 1/4th the time of ordinary copy
•   Hardware to Hardware transfer – uses DMA of disk
-   The above three techniques can be used for file IO
-   NIO for socket provides asynchronous read write asynchronous accept behavior

Courtesy, Source, References & Regards: brother2

While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright@2009-2011 by KuGuNi.com. All Rights Reserved.