Comments (6)
From [email protected] on March 12, 2009 05:26:48
Owner: jloden
from psutil.
From [email protected] on March 12, 2009 09:34:43
Actually for memory leak testing I used process_listing.py:
import psutil
import sys
import os
h = open("process_listing.pid", 'w')
h.write(str(os.getpid()))
h.close()
try:
run_count = 0
while (run_count < 20000):
run_count = run_count + 1
sys.stdout.write("\r\r%s" % run_count)
sys.stdout.flush()
try:
cmdline = psutil.Process(0).cmdline
except Exception, e:
print "\n"
print "Exception for PID 0: %s" % e
continue
PID = -1
for i in psutil.get_process_list():
PID = i.pid
try:
cmdline = i.cmdline
except psutil.NoSuchProcess:
continue
except Exception, e:
print "\n"
print "Exception for PID %s: %s" % (PID, e)
continue
except:
os.remove("process_listing.pid")
I used that to run a loop iterating over as much of the code as possible in the
background by calling str() on a Process object, then used top or ps on UNIX
platforms, or taskmgr on Windows, to monitor the process memory usage. Some shifting
of memory usage is normal, as long as it doesn't climb steadily and remains somewhere
around a consistent amount it means there are most likely no memory leaks.
Ideally psutil will support memory statistics in the next release and we can use
psutil itself to monitor for memory leaks in a cross-platform way without manually
checking the memory usage. Then we can create a self-contained script called
something like test/memory_usage.py that runs a bunch of iterations (I'd guess that a
few thousand is enough to verify a leak) and looks for memory usage climbing beyond a
pre-set threshold.
Status: Accepted
Attachment: process_listing.py
from psutil.
From [email protected] on March 12, 2009 09:38:10
Putting this as blocked on Issue #38 (per-process memory statistics support) for now. https://code.google.com/p/psutil/issues/detail?id=38
Blockedon: 38
from psutil.
From [email protected] on March 25, 2009 05:18:49
Added as r308 .
For me it works fine on every platform except Windows where test__str__ and
test_get_pid_list fail (not always but quite often).
Status: Started
from psutil.
From [email protected] on March 25, 2009 06:05:45
Windows wasn't the only platform on which such test was failing since Jay told me it
was failing also on OS X every now and then.
We noticed that every time there was a difference in the memory usage it was always
of 4096 bytes, no matter how many times the loop was repeated. r315 modifies the script so that if we don't go over 4096 bytes of difference between
step 2 and step 1 the test is considered valid.
As of now I'm not aware of any failure on any platform so I guess we can consider
this one fixed.
Status: Fixed
from psutil.
From g.rodola on March 02, 2013 03:47:16
Updated csets after the SVN -> Mercurial migration: r308 == revision 126d2d3a5674 r315 == revision dcd82bc6d9ff
from psutil.
Related Issues (20)
- [Windows11] Unable to install psutil on pypy 3.9.18 with MSVC 14.38.33130 - Error LNK2001 HOT 3
- [Windows] recognize "Secure System" process name HOT 1
- [Windows] ARM64 build HOT 1
- [Linux] Failing to compile latest version on on lder compiler HOT 3
- [Linux] disk_partitions() returns incorrect block device for bind-mounts
- An API for monitoring new PIDs / processes
- [Linux] Process.children() hogs CPU
- [Ubuntu] Child process cpu_percent() returns 0 HOT 3
- [Windows] Missing NICS in psutil.net_if_addrs() when no IP protocol is set
- [MacOS] calling psutil.net_connections leads to deadlock of syncthing, tailscaled and qbittorrent processes. HOT 1
- [macOS] error: use of undeclared identifier 'kIOMainPortDefault'
- [Linux] psutil.tests.test_linux.TestSystemVirtualMemoryAgainst tests failing
- [Linux] psutil.tests.test_linux.TestRootFsDeviceFinder.test_disk_partitions_mocked: IndexError: list index out of range
- [SUNOS] `Process.cmdline()` does not handle spaces properly HOT 3
- [SunOS] `saved=None` confuses `TestFetchAllProcesses.test_all`
- [Windows] `pid_exists()` and `Process()` disagree on whether a pid exists when ERROR_ACCESS_DENIED HOT 3
- [macOS] v. 5.9.7 broken on macOS < 10.13: `if_dl.h: error: unknown type name 'u_char'; did you mean 'char'?` HOT 1
- [macOS] error: unknown type name 'CFTimeInterval' HOT 1
- Core usage anomaly
- [macOS] error: field has incomplete type 'struct sockaddr'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psutil.