- Create Objects locally (method level) as much as possible. Keeping objects at Object Level or Class Level blocks the memory for the life time of Object or till class gets unloaded.
- List should be browsed using size() and index in for loop or other loops, rather than using Iterator to iterate the List. Using index is faster than using Iterator.
- When large size of text are used in program, always prefer StringBuffer than String. StringBuffer objects will get deleted once the program ends, but String objects don't get deleted from the JVM. Read Perm-Generation for more details.
- Never say hashMap.containsKey("key") to see the item is present in map or not and after that retrieve it using hashMap.get("key"). containsKey() and get() use same methods internally to find elements in a map. Better do hashMap.get("key") and do null check on the value retrieved from the hashMap using key.
Amazon
Monday, February 27, 2012
Core Java - Key Performance Optimization
Subscribe to:
Post Comments (Atom)
Amazon Best Sellors
TOGAF 9.2 - STUDY [ The Open Group Architecture Framework ] - Chap 01 - Introduction
100 Feet View of TOGAF What is Enterprise? Collection of Organization that has common set of Goals. Enterprise has People - organized by co...
-
100 Feet View of TOGAF What is Enterprise? Collection of Organization that has common set of Goals. Enterprise has People - organized by co...
-
Dead-letter queues The dead-letter queue (or undelivered-message queue) is the queue to which messages are sent if they cannot be routed to...
-
01002 A DISCONNECT error occurred. 01003 Null values were eliminated from the argument of a column function. 01004 The value of a string was...
No comments:
Post a Comment