Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
Since JDK 1.2, the generational garbage collector has reduced memory allocation costs to low levels, in many cases lower than C or C++. Generational garbage collection reduces garbage collection costs by grouping objects into generations. The _younger generation_ consists of short-lived objects. The GC performs a minor collection on the younger generation when it fills up with dead objects \[java:[Oracle 2010a|AA. Bibliography#OracleReferences#Oracle 10]\]. Improved garbage collection algorithms have reduced the cost of garbage collection  so that it is proportional to the number of live objects in the younger generation rather than to the total number of objects allocated since the last garbage collection.

Wiki Markup
Note that objects in the younger generation that persist for longer durations are _tenured_ and are moved to the _tenured generation_. Few younger generation objects continue to live through to the next garbage collection cycle. The rest become ready to be collected in the impending collection cycle \[java:[Oracle 2010a|AA. Bibliography#OracleReferences#Oracle 10]\].

With generational GCs, use of short-lived immutable objects is generally more efficient than use of long-lived mutable objects, such as object pools. Avoiding object pools improves the garbage collector's efficiency. Object pools bring additional costs and risks: they can create synchronization problems and can require explicit management of deallocations, possibly creating problems with dangling pointers. Further, determining the correct amount of memory to reserve for an object pool can be difficult, especially for mission-critical code. Use of long-lived mutable objects remains appropriate in cases where allocation of objects is particularly expensive (for example, when performing multiple joins across databases). Similarly, object pools are an appropriate design choice when the objects represent scarce resources, such as thread pools and database connections.

...

Wiki Markup
Program logic occasionally requires tight control over the lifetime of an object referenced from a local variable. In the unusual cases where such control is necessary, use a lexical block to limit the scope of the variable because the garbage collector can collect the object immediately when it goes out of scope \[java:[Bloch 2008|AA. Bibliography#BlochReferences#Bloch 08]\].

This compliant solution uses a lexical block to control the scope - and, consequently, the lifetime - of the buffer object.

...

Wiki Markup
When using this pattern, the Null object must be a singleton and must be final. It may be either public or private, depending on the overall design of the {{DataElement}} class. The state of the Null object should be immutable after creation; this can be enforced either by use of final fields or by explicit code in the methods of the {{DataElement}} class. See \[java:[Grand 2002|AA. Bibliography#GrandReferences#Grand 02]\] "Chapter 8, Behavioral patterns, the Null Object" for additional information on this design pattern.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="60ca483be1c96655-e8aba908-4fb94667-9f8391f2-fb4d53f985ea28541485a951"><ac:plain-text-body><![CDATA[

[java:[API 2006

AA. Bibliography#API References#API 06]]

Class System

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="596caa3e39d8623c-6bf4e366-43a5432c-a3818437-0cafd4ae9a4ab7edbed437b9"><ac:plain-text-body><![CDATA[

[java:[Bloch 2008

AA. Bibliography#Bloch References#Bloch 08]]

Item 6: "Eliminate obsolete object references"

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="2cec14f6dd480424-6a832032-4a444f1c-b880bf94-8817721ad76e59021e99f007"><ac:plain-text-body><![CDATA[

[java:[Coomes 2007

AA. Bibliography#Coomes References#Coomes 07]]

Garbage Collection Concepts and Programming Tips

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="cfcd1cf75bb7fae4-6ff86be9-4d134139-92ffba21-03d56e05012f68b47fce1236"><ac:plain-text-body><![CDATA[

[java:[Goetz 2004

AA. Bibliography#Goetz References#Goetz 04]]

Java theory and practice: Garbage collection and performance

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4f73f0a36ec65262-6023ef08-455e481b-b3c285ee-7e280d7a99c6c4936635fff2"><ac:plain-text-body><![CDATA[

[java:[Lo 2005

AA. Bibliography#Lo References#Lo 05]]

Security Issues in Garbage Collection

]]></ac:plain-text-body></ac:structured-macro>

...