In my Zope site I have classes derived from the mixin Sync.Synchronized,
because the objects derived from my classes must be thread-safe. Lately
I've being experiencing serious memory leaks, with the result that after
a couple of days Zopes memory usage reaches a couple of hundred megabytes in
size, and Zope stops responding.
In an attempt to track down the problem, I have been using the Zope debug
section of the management interface, and I noticed that the refcount of
Sync.Synchronized increases by about 200 everytime my site receives a
get request. These reference counts never decrease.
To help me understand the problem, I wrote a small test harness consisting
of two files. The first, test1.py, looks like this:
# Create a singleton object. There should only be one of these.
## end of test1.py
The second file, test.py, looks like this:
# call method bar on object foo_ob.
print '%d - %d' % (count, sys.getrefcount(Sync.Synchronized))
## end of test.py
This code just imports test1, and makes lots of calls to the bar()
method of the single foo_ob.
The results of running test.py is
1 - 11
2 - 12
3 - 13
4 - 14
5 - 15
6 - 16
7 - 17
8 - 18
9 - 19
10 - 20
11 - 21
12 - 22
13 - 23
14 - 24
15 - 25
16 - 26
17 - 27
18 - 28
19 - 29
20 - 30
21 - 31
22 - 32
23 - 33
24 - 34
25 - 35
26 - 36
27 - 37
28 - 38
29 - 39
Note how the refcount for Sync.Synchronized keeps increasing.
I searched on Google about this, and found this message:
which implies that there was a problem with refcounts.
So, finally, we come to the question, or rather questions, since
there are two:
1. Why does the refcount of Sync.Synchronized keep increasing?
2. Am I chasing a red herring here? That is, does the "Top Refcounts"
part of the Zope Debug screen merely show that there is one instance
of an object, and N references, and consequently nothing to worry
about?. If so, is there a way I can find out how many real instances
Any advice greatly appreciated.
Thanks in advance,
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -