[Twisted-Python] Use twisted.python.logfile.LogFile wirte log,Memory can not be released, does anybody familiar with or encounter such a situation?
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 .......
On Mon, 15 Sep 2008 19:31:59 +0800, echo <dotecho@gmail.com> wrote:
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
I ran the test code on Ubuntu Hardy but I don't see any memory problems. I let the program run for about two minutes and memory remained constant for the entire time. LogFile doesn't do very much besides write to a Python file object. Can you reproduce the memory problem just using a file without using LogFile? Jean-Paul
2008/9/15 Jean-Paul Calderone <exarkun@divmod.com>
I ran the test code on Ubuntu Hardy but I don't see any memory problems. I let the program run for about two minutes and memory remained constant for the entire time.
LogFile doesn't do very much besides write to a Python file object. Can you reproduce the memory problem just using a file without using LogFile?
Hi, Jean-Paul, thank you for reply and test;) I open a single file, write the same data, memory is not automatically released, after i delete the file, memory released..
participants (2)
-
echo
-
Jean-Paul Calderone