Azure Websites - Increase Java / Tomcat heap size?

Azure Websites - Increase Java / Tomcat heap size?



I have been trying to increase the heap size within my Azure website instance without any luck.. I have built a web.config file per some recommendations and put it in the /site/wwwroot folder but it doesn't seem to be overriding the default. For reference, my web.config looks like;


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>

<httpPlatform processPath="%programfiles(x86)%apache-tomcat-7.0.50binstartup.bat">
<environmentVariables>
<environmentVariable name="CATALINA_HOME" value="%programfiles(x86)%apache-tomcat-7.0.50"/>
<environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true -Xms128m -Xmx512m"/>
<environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT%"/>
</environmentVariables>
</httpPlatform>
</system.webServer>





Any suggestions would be greatly appreciated by both myself and I'm sure others who are trying to do the same thing as well.



Thank you!




4 Answers
4



You have two options:



My preferred way (Removes dependency on specific minor version of Tomcat 7):


processPath="%AZURE_TOMCAT7_HOME%binstartup.bat"



The other way (here programfiles points to the Program Files (x86) folder:


programfiles


Program Files (x86)


processPath="%programfiles%apache-tomcat-7.0.50binstartup.bat"






This didn't help. Below is the content of my web.config file and it gave ERROR 500. ` <httpPlatform processPath="%AZURE_TOMCAT85_HOME%binstartup.bat"> <environmentVariables> <environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT%" /> <environmentVariable name="CATALINA_HOME" value="%AZURE_TOMCAT85_HOME%" /> <environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true -Xmx256m -Xmx512m -Xms1g"/> </environmentVariables> </httpPlatform>`

– Vivek Dani
May 8 '17 at 5:45




Remove those settings in “JAVA_OPTS” and add them into “CATALINA_OPTS” as below, because java heap size should go under CATALINA_OPTS:


<httpPlatform processPath="%AZURE_TOMCAT85_HOME%binstartup.bat">
<environmentVariables>
<environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT% -Xms512m -Xmx2048m" />
<environmentVariable name="CATALINA_HOME" value="%AZURE_TOMCAT85_HOME%" />
</environmentVariables>
</httpPlatform>



Abdenaceur's solution above is the "Microsoft" answer however it did not work for us. Instead of this:


<environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT% -Xms512m -Xmx2048m" />



what worked for us was this:


<httpPlatform processPath="%JAVA_HOME%binjava.exe" arguments="-Djava.net.preferIPv4Stack=true -Dspring.profiles.active=%spring.profiles.active% -Dserver.port=%HTTP_PLATFORM_PORT% -Xms512m -Xmx2048m -jar &quot;%HOME%sitewwwrootBLA-0.0.1-SNAPSHOT.jar&quot;">
</httpPlatform>



So the complete file is:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%JAVA_HOME%binjava.exe" arguments="-Djava.net.preferIPv4Stack=true -Dspring.profiles.active=%spring.profiles.active% -Dserver.port=%HTTP_PLATFORM_PORT% -Xms512m -Xmx2048m -jar &quot;%HOME%sitewwwrootBLAA_Api-0.0.1-SNAPSHOT.jar&quot;">
</httpPlatform>
</system.webServer>
</configuration>



What worked for us is adding the CATALINA_OPTS at "Application settings" in the section "Application settings".


CATALINA_OPTS



E.g. set it to -Xmx20m and reboot your application and you will likely get an OutOfMemory Error instantly because 20MB is not enough.
If that worked you can obviously adjust -Xmx to your needs and reboot again.


-Xmx20m



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)