All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.findbugs.EMF_BAD_ASSIGNMENT.html Maven / Gradle / Ivy

Go to download

Sanity4J was created to simplify running multiple static code analysis tools on the Java projects. It provides a single entry point to run all the selected tools and produce a consolidated report, which presents all findings in an easily accessible manner.

There is a newer version: 1.8.2
Show newest version


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.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy