resources.report.rules.findbugs.EMF_BAD_ASSIGNMENT.html Maven / Gradle / Ivy
Show all versions of sanity4j Show documentation
EMF: Bad Assignment (EMF_BAD_ASSIGNMENT)
EMF: Bad Assignment (EMF_BAD_ASSIGNMENT)
Investigation of production WebSphere Portal
Java Heap Dumps revealed that HTTP sessions
were "hanging on" to a large number of EMF types (which use
up a lot of memory) within the Portal applications. Tracking back
some Java reference chains within the heapdumps, this seems to be
due to some accidental "shallow copying" of some of the Lists
returned within the SDOs. i.e.
modelObject.setStringList(sdo.getStringList())
and
public void setStringList(final List stringList) {
this.stringList = stringList;
}
type behaviour, rather than:
modelObject.setStringList(new ArrayList(sdo.getStringList());
or
public void setStringList(final List stringList) {
this.stringList = new ArrayList(stringList);
}
(etc... for more complicated object lists...)
The first example is causing the model object to store
a reference to an EMF EcoreEList rather than a simple list
of Strings. Because the EcoreEList maintains a reference
to its "owning" object, which via another set of references
means that the entire SDO from which this list was obtained
stays in memory.