[New-bugs-announce] [issue31896] In function define class inherit ctypes.structure, and using ctypes.pointer leak memory

Yang Big report at bugs.python.org
Sun Oct 29 23:53:39 EDT 2017


New submission from Yang Big <qq519476132 at gmail.com>:

Here my code:
  2 import sys
  3 import ctypes
  4      
  5      
  6 def hi():
  7     class timespec(ctypes.Structure):
  8     ┆   """Time specification, as described in clock_gettime(3)."""
  9     ┆   _fields_ = (('tv_sec', ctypes.c_long),
 10     ┆   ┆   ┆   ┆   ('tv_nsec', ctypes.c_long))
 11      
 12      
 13     ts = timespec()
 14     po = ctypes.pointer(ts)
 15      
 16      
 17 def main():
 18     while True:
 19     ┆   test = hi()
 20      
 21 if __name__ == "__main__":
 22     sys  2 import sys
  3 import ctypes
  4      
  5      
  6 def hi():
  7     class timespec(ctypes.Structure):
  8     ┆   """Time specification, as described in clock_gettime(3)."""
  9     ┆   _fields_ = (('tv_sec', ctypes.c_long),
 10     ┆   ┆   ┆   ┆   ('tv_nsec', ctypes.c_long))
 11      
 12      
 13     ts = timespec()
 14     po = ctypes.pointer(ts)
 15      
 16      
 17 def main():
 18     while True:
 19     ┆   test = hi()
 20      
 21 if __name__ == "__main__":
 22     sys.exit(main())

run this code, i find that the program occupy more and more VmRss
my python is 2.7.11, in python3 i also find this problem. 
   Is this normal?I am a newbie with python, not very familiar with some 
python's internal principle. 
   Tanks.

----------
components: ctypes
messages: 305204
nosy: Yang Big, amaury.forgeotdarc, belopolsky, meador.inge
priority: normal
severity: normal
status: open
title: In function define class inherit ctypes.structure, and using ctypes.pointer leak memory
type: resource usage
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31896>
_______________________________________


More information about the New-bugs-announce mailing list