osate / osate2

Open Source AADL2 Tool Environment
http://osate.org
Eclipse Public License 2.0
39 stars 8 forks source link

Memory leak in AADL workspace build #1726

Closed smithdtyler closed 5 years ago

smithdtyler commented 5 years ago

Summary

Java heap usage grows with each OSATE workspace build and cannot be garbage collected, eventually resulting in an OutOfMemoryException.

I created a minimum working example here: https://github.com/smithdtyler/osatememoryleaker

To run the example,

Watch:

screen shot 2019-03-05 at 8 49 52 am

smithdtyler commented 5 years ago

I have suspicions about the cause of this problem (but didn't want to pollute the top level issue description). Memory Analysis Tool (MAT) suggests a couple of likely problem spots:

156 instances of "org.eclipse.xtext.util.OnChangeEvictingCache$CacheAdapter", loaded by "org.eclipse.xtext.util" occupy 190,713,528 (64.20%) bytes. These instances are referenced from one instance of "java.util.WeakHashMap$Entry[]", loaded by ""

MAT reports this on a heap dump generated after approximately 156 calls to

 ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD,
                new NullProgressMonitor());
lwrage commented 5 years ago

@smithdtyler What happens when you run the same test on OSATE 2.3.7?

lwrage commented 5 years ago

It's an issue in AnnexParseUtil. It has been around for years but now is the first time it caused an OOM. AnnexParseUtil has a HashMap that caches parse results. uses a field of the value as the key!