title: OutOfMemoryError: Java heap space at java.util.Arrays.copyOfRange
body: <p>This is the error that is thrown in the GWT DevMode console when passing an image base64 String (abour ~360KB in size) to a GWT method with String param:</p>
  
  <blockquote>
    <p>java.lang.OutOfMemoryError: Java heap space   at
    java.util.Arrays.copyOfRange(Arrays.java:2694)    at
    java.lang.String.(String.java:234)  at
    java.lang.StringBuilder.toString(StringBuilder.java:405)  at
    org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl$23._marshall1(MarshallerFactoryImpl.java:1310)
      at
    org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl$23.marshall(MarshallerFactoryImpl.java:1326)
      at
    org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl$23.marshall(MarshallerFactoryImpl.java:1)
      at
    org.jboss.errai.marshalling.client.marshallers.QualifyingMarshallerWrapper.doNotNullMarshall(QualifyingMarshallerWrapper.java:93)
      at
    org.jboss.errai.marshalling.client.marshallers.AbstractNullableMarshaller.marshall(AbstractNullableMarshaller.java:29)
      at
    org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl$24.marshall(MarshallerFactoryImpl.java:1402)
      at
    org.jboss.errai.marshalling.client.api.MarshallerFactoryImpl$24.marshall(MarshallerFactoryImpl.java:1)
      at
    org.jboss.errai.marshalling.client.Marshalling.toJSON(Marshalling.java:83)
      at
    org.jboss.errai.enterprise.client.jaxrs.MarshallingWrapper.toJSON(MarshallingWrapper.java:32)
      at
    org.jboss.errai.enterprise.client.jaxrs.JaxrsProxyLoaderImpl$1com_myapp_client_shared_service_PasteServiceImpl.createPaste(JaxrsProxyLoaderImpl.java:194)
      at
    com.myapp.client.local.PastePage.onPasteImage(PastePage.java:257)
      at com.myapp.client.local.PastePage$4$1.run(PastePage.java:162)
      at com.google.gwt.user.client.Timer.fire(Timer.java:149)    at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)     at
    com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
      at
    com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
      at
    com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
      at
    com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
      at
    com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
      at
    com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
      at
    com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
      at
    com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
      at
    com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
      at com.google.gwt.core.client.impl.Impl.apply(Impl.java)    at
    com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)    at
    sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source)</p>
  </blockquote>
  
  <p>Looking at the logs it does not look like its a client-side issue, more of a marshalling issue.</p>