Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363675 - ClientResources_Test failed with OutOfMemoryError
Summary: ClientResources_Test failed with OutOfMemoryError
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.5 M4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-14 02:33 EST by Ivan Furnadjiev CLA
Modified: 2011-11-14 15:52 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Furnadjiev CLA 2011-11-14 02:33:21 EST
When executing the complete test suite, two of the tests in ClientResources_Test (testRegisterResourcesDebug and testRegisteredContentDebug) failed with
java.lang.OutOfMemoryError: Java heap space
	at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:334)
	at java.lang.StringCoding.encode(StringCoding.java:378)
	at java.lang.String.getBytes(String.java:812)
	at org.eclipse.rwt.internal.resources.ResourceUtil.readText(ResourceUtil.java:104)
	at org.eclipse.rwt.internal.resources.ResourceUtil.read(ResourceUtil.java:44)
	at org.eclipse.rwt.internal.resources.ResourceManagerImpl.register(ResourceManagerImpl.java:206)
	at org.eclipse.swt.internal.widgets.displaykit.ClientResources.registerJavascriptLibraryFile(ClientResources.java:379)
	at org.eclipse.swt.internal.widgets.displaykit.ClientResources.registerJavascriptFiles(ClientResources.java:335)
	at org.eclipse.swt.internal.widgets.displaykit.ClientResources.registerResources(ClientResources.java:315)
	at org.eclipse.swt.internal.widgets.displaykit.ClientResources_Test.testRegisteredContentDebug(ClientResources_Test.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at junit.framework.TestSuite.runTest(TestSuite.java:232)
	at junit.framework.TestSuite.run(TestSuite.java:227)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Comment 1 Ivan Furnadjiev CLA 2011-11-14 12:43:08 EST
Fixed by adding -Xmx128m VM argument to the RWTAllTestSuite launch configuration. Some theme manager cleanups in the tests added too.
Comment 2 Ralf Sternberg CLA 2011-11-14 15:52:56 EST
I was able to reproduce the OOM by setting the max heap size to 64M (the default for 32bit Sun VMs, 64bit VMs have 30% more [1]).

Looking at the heap dump, we found *a lot of* large Strings, e.g. there are 37 instances of ThemeManager sticking on different ApplicationContexts, each of which keeping references to the contents of all registered appearance files. This can be optimized, see bug 363745.

The OOM actually occurs when the ResourceUtil reads the entire content of a large file into memory in order to copy it. This can also be done more efficiently, bug 363747.

[1] http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#64bit_heap_defaults