title: Tomcat 7.0 Out Of Caused by: java.lang.OutOfMemoryError: Java heap space in Windoes Server
body: <p>I am using Tomcat 7.0 And Windows Server OS 2008.
  I am trying to upload 30 MB File when i try to read file then following error is generating.</p>
  
  <p>I have 6 GB RAM and out of 6GB 2GB is free.</p>
  
  <pre><code>Caused by: java.lang.OutOfMemoryError: Java heap space
      at java.awt.image.DataBufferInt.&lt;init&gt;(DataBufferInt.java:41)
      at java.awt.image.Raster.createPackedRaster(Raster.java:458)
      at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
      at java.awt.image.BufferedImage.&lt;init&gt;(BufferedImage.java:312)
      at net.coobird.thumbnailator.util.BufferedImages.copy(Unknown Source)
      at net.coobird.thumbnailator.tasks.io.OutputStreamImageSink.write(Unknown Source)
      at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.write(Unknown Source)
      at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
      at net.coobird.thumbnailator.Thumbnails$Builder.toOutputStream(Unknown Source)
      at com.toocoolproductions.model.service.impl.UserSettingsServiceImpl.getScaledImage(UserSettingsServiceImpl.java:332)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  </code></pre>
  
  <p><strong>setavn.bat</strong></p>
  
  <pre><code>if exist "%CATALINA_HOME%/jre1.6.0_20/win" (
      if not "%JAVA_HOME%" == "" (
          set JAVA_HOME=
      )
  
      set "JRE_HOME=%CATALINA_HOME%/jre1.6.0_20/win"
  )
  
  set "JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF8 -Djava.net.preferIPv4Stack=true -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=GMT -Xmx1024m -Xms1024M  -XX:PermSize=256m -XX:MaxPermSize=256m"
  echo %JAVA_OPTS%;
  </code></pre>
  
  <p>I try a lot after chages settings for -Xmx1024m -Xms1024M  -XX:PermSize=256m -XX:MaxPermSize=256m for changes different-diffrent sizes but those are not working for me.</p>
  
  <p>Please help me to solve this problem. </p>