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