Versions Compared

Key

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

...

This behavior is both desirable and correct for data that potentially contains arbitrary object graphs, especially when the graphs are fully allocated and constructed prior to serialization. However, it can lead to memory exhaustion when serializing data that both lacks references to other objects being serialized and also can be allocated in part or in full after serialization has begun. One such example of such data is serializing a data stream from an external sensor. In such cases, programs must take additional action to avoid memory exhaustion. That is, programs reading in independent serialized data must reset the object cache between reads to prevent memory exhaustion.

...

This noncompliant code example reads and serializes data from an external sensor. Each invocation of the readSensorData() method returns a newly created SensorData instance, each containing a megabyte of data. SensorData instances contain are pure data streams, containing data and arrays , but lack any lacking references to other SensorData objects; this is a pure data stream.

The As already described, the ObjectOutputStream maintains a cache of previously-written objects, as discussed above; consequently, . Consequently, all SensorData objects remain alive until the cache itself becomes garbage. This can result in an OutOfMemoryError, because the stream remains open while new objects are being written to it.

...

Memory and resource leaks during serialization can consume all available memory result in a resource exhaustion attack or crash the JVM.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

SER10-J

low

unlikely

low

P3

L3

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6fc88f9cd2500f77-341cc1e7-442449ea-a1108930-d2821042a114f1cff21b3251"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

 

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6ac01841edddd05a-651700f7-4b6c422a-91c89037-02a9e42904dd295f5b79517a"><ac:plain-text-body><![CDATA[

[[Harold 2006

AA. Bibliography#Harold 06]]

13.4. Performance

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6b9f420f81d6a272-ed09e45b-410e461f-a190bf9f-6665dbad24b617c080c32069"><ac:plain-text-body><![CDATA[

[[Sun 2006

AA. Bibliography#Sun 06]]

"Serialization specification"

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

...