Use twisted.python.logfile.LogFile wirte log,Memory can not be
released, does anybody familiar with or encounter such a situation?
Environment: FREEBSD 6.3 RELEASE
twisted svn trunk today
Description of the problem
Use "TOP" command observe the used memory, memory first use the BUF, if buf>111M, then don't use buf
and use WIRED, Wired to around 132 M, and then use Inact
If during the service manually delete the generated file. Memory will be released.
twisted.python.logfile.LogFile default log file will be closed at 1 M
size, and re-open a file, how the file is closed, but the memory still
not released?
sorry for my poor english.. thank you
**test code:
#!/usr/local/bin/python
import datetime
import os
from twisted.python import logfile
class LogFile2(logfile.LogFile):
'''
'''
def rotate(self):
"""
Rotate the file and create a new one.
If it's not possible to open new logfile, this will fail silently,
and continue logging to old logfile.
"""
if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)):
return
logs = self.listLogs()
logs.reverse()
for i in logs:
if self.maxRotatedFiles is not None and i >= self.maxRotatedFiles:
os.remove("%s.%d" % (self.path, i))
else:
os.rename("%s.%d" % (self.path, i), "%s.%d" % (self.path, i + 1))
self._file.close()
print self._file, 'closed'
os.rename(self.path, "%s.1" % self.path)
self._openFile()
i=10000000
log = LogFile2('test_logfile.log', '/home/echo/tmp/test/')
while i:
msg = '%s: test_test_test_test\r\n' % str(i)
log.write(msg)
i=i-1
log.close()
**result。
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'r+' at 0x827ccc8> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827c458> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827ccc8> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827c458> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827ccc8> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827c458> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827ccc8> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827c458> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827ccc8> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827c458> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827ccc8> closeed
<closed file '/home/echo/tmp/test/test_logfile.log', mode 'w+' at 0x827c458> closeed
.......