added some code for debugging memory issue
This commit is contained in:
parent
7008993545
commit
4550100675
|
@ -30,6 +30,14 @@
|
|||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Define the memory logging appender. -->
|
||||
<appender name="MEM" class="org.apache.log4j.FileAppender">
|
||||
<param name="File" value="/home/erbo/venice.memory.log"/>
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d [%x] - %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Turn down the standard detail in some areas -->
|
||||
<category name="com.silverwrist.util.ServletMultipartHandler">
|
||||
<priority value="debug"/>
|
||||
|
@ -38,6 +46,11 @@
|
|||
<priority value="fatal"/>
|
||||
</category>
|
||||
|
||||
<category name="MEMLOG" additivity="false">
|
||||
<priority value="info"/>
|
||||
<appender-ref ref="MEM"/>
|
||||
</category>
|
||||
|
||||
<!-- Define the root configuration for logging. -->
|
||||
<root>
|
||||
<priority value="debug"/>
|
||||
|
@ -45,7 +58,3 @@
|
|||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-04 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -79,7 +79,8 @@ public abstract class BaseServlet extends HttpServlet
|
|||
private static final String ENGINE_INIT_PARAM = "venice.config";
|
||||
private static final String UICONFIG_INIT_PARAM = "ui.config";
|
||||
|
||||
private static Category logger = Category.getInstance(BaseServlet.class);
|
||||
private static Logger logger = Logger.getLogger(BaseServlet.class);
|
||||
private static Logger memlog = Logger.getLogger("MEMLOG");
|
||||
|
||||
private static VeniceUISessionFactory factory = new HttpSessionFactory();
|
||||
|
||||
|
@ -127,6 +128,7 @@ public abstract class BaseServlet extends HttpServlet
|
|||
|
||||
} // end catch
|
||||
|
||||
String str_request = the_request.toString();
|
||||
String default_location = the_request.getLocation();
|
||||
|
||||
// log the username with all log messages, if the user is logged in
|
||||
|
@ -173,12 +175,19 @@ public abstract class BaseServlet extends HttpServlet
|
|||
{ // filter out RuntimeExceptions and rethrow them
|
||||
logger.error("BaseServlet caught runtime exception" + e.getClass().getName()
|
||||
+ " in commonProcess",e);
|
||||
throw (RuntimeException)e;
|
||||
throw new ServletException(e);
|
||||
|
||||
} // end if
|
||||
|
||||
my_output = translateException(the_request,e);
|
||||
|
||||
} // end catch
|
||||
catch (VirtualMachineError e)
|
||||
{ // OutOfMemoryError and similar come here...
|
||||
System.gc(); // garbage collect so we have enough space to handle the error
|
||||
logger.error("Virtual machine failure " + e.getClass().getName() + " in commonProcess",e);
|
||||
throw new ServletException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -198,6 +207,13 @@ public abstract class BaseServlet extends HttpServlet
|
|||
the_request.outputRaw(my_output.toString());
|
||||
|
||||
} // end try
|
||||
catch (VirtualMachineError e)
|
||||
{ // OutOfMemoryError and similar come here...
|
||||
System.gc(); // garbage collect so we have enough space to handle the error
|
||||
logger.error("Virtual machine failure " + e.getClass().getName() + " in commonProcess(2)",e);
|
||||
throw new ServletException(e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // end the request
|
||||
the_request.end();
|
||||
|
@ -206,7 +222,12 @@ public abstract class BaseServlet extends HttpServlet
|
|||
|
||||
} // end try
|
||||
finally
|
||||
{ // make sure and pop the diagnostic context, if it was pushed
|
||||
{ // log memory usage
|
||||
Runtime r = Runtime.getRuntime();
|
||||
memlog.info("After: " + str_request + " Cur: " + r.totalMemory() + " Max: " + r.maxMemory() + " Free: "
|
||||
+ r.freeMemory());
|
||||
|
||||
// make sure and pop the diagnostic context, if it was pushed
|
||||
if (record_user)
|
||||
NDC.pop();
|
||||
|
||||
|
|
|
@ -756,6 +756,19 @@ public class RequestImpl implements RequestInput
|
|||
|
||||
} // end expandServletPath
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class Object
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("{RequestImpl from [");
|
||||
buf.append(request.getRemoteAddr()).append("] for ").append(request.getServletPath()).append("}");
|
||||
return buf.toString();
|
||||
|
||||
} // end toString
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ServiceProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user