Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E287710F34 for ; Wed, 5 Feb 2014 13:37:17 +0000 (UTC) Received: (qmail 6942 invoked by uid 500); 5 Feb 2014 13:37:15 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 6639 invoked by uid 500); 5 Feb 2014 13:37:15 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 6628 invoked by uid 99); 5 Feb 2014 13:37:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Feb 2014 13:37:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.131] (HELO eos.apache.org) (140.211.11.131) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Feb 2014 13:37:12 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id AB50ED3B for ; Wed, 5 Feb 2014 13:36:51 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Wed, 05 Feb 2014 13:36:51 -0000 Message-ID: <20140205133651.30461.23323@eos.apache.org> Subject: =?utf-8?q?=5BTomcat_Wiki=5D_Trivial_Update_of_=22OutOfMemory=22_by_Konsta?= =?utf-8?q?ntinKolinko?= Auto-Submitted: auto-generated X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for ch= ange notification. The "OutOfMemory" page has been changed by KonstantinKolinko: https://wiki.apache.org/tomcat/OutOfMemory?action=3Ddiff&rev1=3D11&rev2=3D12 Comment: Add TOC, remove dead link #format wiki #language en + = + <> = =3D How to Deal With Out Of Memory Errors =3D = @@ -18, +20 @@ An Out Of Memory can be thrown by several causes: = * A servlet trying to load a several GBytes file into memory will surely= kill the server. These kind of errors must be considered a simple bug in o= ur program. - * To compensate for the data your servlet tries to load, you increase th= e heap size so that there is no room to create the stack size for the threa= ds that need to be created. The memory required by each thread will vary b= y OS but can be as high as 2M by default and in some OS's (like Debian Sarg= e) is not reducible with the -Xss parameter. [[http://goobsoft.homeip.net/W= iki.jsp?page=3DJavaDebianTuning|1]] Rule of Thumb, use no more than 1G for= heap space in a 32-bit web application. + * To compensate for the data your servlet tries to load, you increase th= e heap size so that there is no room to create the stack size for the threa= ds that need to be created. The memory required by each thread will vary b= y OS but can be as high as 2M by default and in some OS's (like Debian Sarg= e) is not reducible with the -Xss parameter. Rule of Thumb, use no more tha= n 1G for heap space in a 32-bit web application. * Deep recursive algorithms can also lead to Out Of Memory problems. In = this case, the only fixes are increasing the thread stack size ({{{-Xss}}})= , or refactoring the algorithms to reduce the depth, or the local data size= per call. * A webapp that uses lots of libraries with many dependencies, or a serv= er maintaining lots of webapps could exhauste the JVM PermGen space. This s= pace is where the VM stores the classes and methods data. In those cases, t= he fix is to increase this size. The Sun VM has the flag {{{-XX:MaxPermSize= }}} that allows to set its size (the default value is 64M) * Hard references to classes can prevent the garbage collector from recl= aiming the memory allocated for them when a ClassLoader is discarded. This = will occur on JSP recompilations, and webapps reloads. If these operations = are common in a webapp having these kinds of problems, it will be a matter = of time, until the PermGen space gets full and an Out Of Memory is thrown. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org