weblogic weblogic.servlet.internal.session.MemorySessionData对象过多导致内存溢出

来源:互联网 发布:淘宝天弘基金怎么赎回 编辑:程序博客网 时间:2024/06/02 02:40

  用MAT分析DUMP文件,可以发现weblogic.servlet.internal.session.MemorySessionData过多,

 SELECT * FROM weblogic.servlet.internal.session.MemorySessionData 对象有120万之多,占用900M的内存。

 当一个用户登陆之后,在会在weblogic里面生成一个MemorySessionData对象,这个对象生命周期是weblogic控制,通过web.xml中的一个配置项。

<session-config>

     <session-timeout>300000</session-timeout> 
</session-config>

这里的单位是分钟

To look for session objects collected in the heap, you first need to know the session persistence method used by the customer's application. The same can be found out from the application's weblogic.xml file. In the example, the following entries are made in the weblogic.xml:

<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
  <session-descriptor>
    <persistent-store-type>replicated</persistent-store-type>
  </session-descriptor>
</weblogic-web-app>

The tag "persistent-store-type" governs which class WLS would internally use to store the session objects; this is important to the debugging aspect while reviewing the heap dump. Valid values for the "persistent-store-type" and the corresponding classes used are listed below.

Persistent Store TypeWLS Implementation Classmemoryweblogic.servlet.internal.session.MemorySessionDatareplicatedweblogic.servlet.internal.session.ReplicatedSessionDataasync-replicatedweblogic.servlet.internal.session.AsyncReplicatedSessionDatafileweblogic.servlet.internal.session.FileSessionDataasync-jdbcweblogic.servlet.internal.session.AsyncJDBCSessionDatajdbcweblogic.servlet.internal.session.JDBCSessionDatacookieweblogic.servlet.internal.session.CookieSessionData

APPLIES TO:

Oracle WebLogic Server - Version 10.3.5 and later
Information in this document applies to any platform.

SYMPTOMS

There is huge consumption of memory in the production environment. A memory dump shows two WebLogic classes as leak suspects:

  • weblogic.servlet.internal.session.MemorySessionContext (66.05%)
  • weblogic.servlet.internal.session.MemorySessionData (21.52%)

CAUSE

The "session-timeout" value in in web.xml is set to 1 hour (3600 seconds) by default. If the session is not invalidated or timed out in application code, each session will live for that full hour, causing objects to accumulate until the container times the session out. Combine this with heavy traffic (so lots of sessions opened), and this causes huge memory consumption.

To find if there are any invalid sessions lingering in the heap after a particular time, it is recommended that the application explicitly call session.invalidate() to invalidate a session after the user logs out. However WLS also provides a mechanism to expire sessions after a specific interval that is referred to as the "session-timeout" parameter in the web.xml. The value set in this element overrides the value set in the TimeoutSecs attribute of the element in the WebLogic-specific deployment descriptor weblogic.xml. If nothing is specified the default value of 3600 seconds is used. See Session Timeout for more information.

SOLUTION

To reduce the memory consumption from HTTP session objects, please follow these steps:

  1. Ensure that the application code explicitly calls session.invalidate() when a user logs out of their session.
  2. Lower the "session-timeout" value set in in web.xml to (for example) 15 minutes.

0 0
原创粉丝点击