I seem to have discovered a memory leak in usb.busses(), though I haven't yet tracked it down in detail. Procedure to expose it:
open two terminal windows. In one, start up a watch with ps: > watch -d -n 0.1 'ps -A H -o spid,%cpu,rsz,nlwp,start,eip,stat,cmd | grep > python' The third column is the amount of memory used by each listed application. (In kB, I believe.) In the other, start up Python: (The numbers left of the ">" are my results for memory used by python before the line executes.) 0 > python 4940 >>> import usb 5040 >>> usb.busses() 5168 >>> usb.busses() 5216 >>> usb.busses() 5220 >>> usb.busses() 5220 >>> a=usb.busses() 5228 >>> a=usb.busses() 5272 >>> a=usb.busses() 5276 >>> a=usb.busses() 5276 >>> usb.busses() 5276 >>> usb.busses() 5276 >>> b=usb.busses() 5328 >>> a=usb.busses() 5328 >>> a=usb.busses() 5328 >>> usb.busses() 5328 >>> b=usb.busses() 5328 >>> I dunno - it seems to stabilize after several calls, and seems to depend on the assignment statement - which may have more to do with Python itself than pyusb - but I don't get this behavior with simple lists... and forcing a call to the garbage-collection routine doesn't recover the memory. Anyone seen this before? Anyone know if it's a feature of pyusb or python? Some Context: Python 2.6 (r26:66714, Feb 3 2009, 20:49:49) [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 OS: Linux 2.6.27.19-3.2-default x86_64 openSUSE 11.1 (x86_64) KDE 4.1.3 "release 4.9" It's probably not a big deal, but I'm using Python code to manage a number of usb devices which occasionally get hot-swapped while I'm trying to talk to 'em. To make sure I have the comm. set up right I have to call usb.busses() on a fairly regular basis. I'm leaking memory in several places, with the result that the code slows substantially over the course of a day. This is just the first leak I've located. Thanks -Sarah --- On Thu, 6/26/08, Abhishek Wadhava <abhishekatma...@gmail.com> wrote: > From: Abhishek Wadhava <abhishekatma...@gmail.com> > Subject: [Pyusb-users] Enquiry about PyUSB > To: pyusb-users@lists.sourceforge.net > Date: Thursday, June 26, 2008, 10:01 AM > Hi.. > I'm trying to make a Software USB based on AVR309 > application note available > at www.atmel.com/dyn/resources/prod_documents/doc2556.pdf > So what basically i'm doing is programming a ATTINY-44 > to do functions of a > USB-driver and when connected to USB port, should be > automatically detected > by the computer. > Now i'm also making a GUI using Tkinter in Python to > read data from the > microcontroller & to write in it. > I was thinking of using pyUSB for this purpose. > but i'm unable to understand how to read and write from > a USB device using > pyUSB. > Please help me in any way in this regard. > Thank U. > > Abhishek Wadhava > 3rd year, ECE, > MANIT, Bhopal(M.P.) > India > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php_______________________________________________ > Pyusb-users mailing list > Pyusb-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pyusb-users ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ Pyusb-users mailing list Pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users