[ZCM] [ZC] 2068/ 1 Request "Leak in Session Data Container"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Tue Apr 11 00:18:11 EDT 2006


Issue #2068 Update (Request) "Leak in Session Data Container"
 Status Pending, Zope/bug critical
To followup, visit:
  http://www.zope.org/Collectors/Zope/2068

==============================================================
= Request - Entry #1 by Anonymous User on Apr 11, 2006 12:18 am

Anything placed in the session data object seems to get leaked. If the session objects are used Zope will consume all available memory.  When all physical memory and swap is exhausted the system will crash.  These are the steps I used to produce the problem on a clean install.

Step 1:
In Zope I created the following script:

session = context.REQUEST.SESSION
s= 'Andy' * 102400;
session['sessiontest1']=s

The size of 's' depends purely on how fast you would like Zope to consume
memory.  On my server this will consume all physical memory in about
1000 calls.

Step 2:
Changed the session_data object timeout to 1 minute.  This is just to
cause the session objects to expire in 1 minute to hurry the test along.
Changed the Max subobjects to 0 (unlimited).  I don't know if this is
needed, but it is how we have our production servers set.

Step 3:
Use ab (apache bench) to call the script 1000 times using 10 concurrent
threads.
This causes Zope to consume over 90% of the memory as one would expect.
The transient object container (/temp_folder/session_data) will now show
1009 objects.  I don't know where the 6-9 extra come from.?

Step 4:
Wait 1-2 minutes for the objects to expire.
Note: I used a browser or ab to access some other resource in Zope and or
the script a number of times.  This was needed to "tickle" the transient
object container's expiration/garbage collection system.  
As expected the transient object container now shows 0 objects.
However, Zope never releases the memory.  You can wait minutes, hours,
days what ever all the while tickling Zope.  Zope will *never* release the
memory until it is restarted.  

THE WORK ARROUND

I created a script called onDelete
Parameter List sdo, toc
sdo.clear()


Then in /temp_folder/session_data I set the Script to call when objects
are deleted to /onDelete

Now when the tests are run the same amount of memory is consumed, but it
is released back to the system when the session objects expire.

CONCLUSION

To me it looks like data placed in the session object are not getting
deleted when the session object expires.  Anything placed in a session
object is essentially leaked.  When the onDelete script explicitly
removes the contents of the session data object the memory leak stops.

==============================================================



More information about the Zope-Collector-Monitor mailing list