This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Possible memory leak in output console
Type: Stage:
Components: Windows Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, kstrauser, ncoghlan
Priority: normal Keywords:

Created on 2004-08-10 17:14 by kstrauser, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg22040 - (view) Author: Kirk Strauser (kstrauser) Date: 2004-08-10 17:14
I've written a bridge adapter to connect my company's 
Unix servers to our Foxpro database, and it runs as a 
command line program under Python 2.3.4 (with Python 
for Windows Extensions build 202) on a Windows XP 
server.  Basically, it listens for incoming SQL queries from 
the Unix servers (via the Python Web Services 
implementation of SOAP),  executes them with ADODB, 
and returns the results via SOAP. 
 
The system works as desired, except that we've been 
triggering a memory leak with the program has been 
running for long periods of time, to the tune of about .5GB 
of memory per month.  I've recently noticed that the rate 
of leak is proportional to the amount of console output 
that the program generates (the debugging level is 
remotely adjustable via a SOAP method), and that I can 
consistently reclaim the memory by the act of minimizing 
the console window. 
 
That is, at this very moment, the window is minimized 
and the task manager is reporting that the application is 
using 64,908KB of memory. 
 
If I restore the window to its normal size, the memory 
allocation stays about the same. 
 
If I then re-minimize the window, usage drops to 280KB.  
It will then gradually increase again until the server 
begins to bog down, at which point I can repeat the 
process of restoring and then minimizing the console 
window. 
 
In other words, leaving the window "open" does not help, 
nor does leaving it minimized; only the act of minimizing 
an "open" window is sufficient to reduce the 
eternally-growing memory footprint.  This is completely 
reproducible, and I was having the same problem with 
Python 2.3.3 before upgrading it yesterday. 
 
msg22041 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2004-08-11 06:33
Logged In: YES 
user_id=1038590

What are you using to measure your 'memory usage'?

If you are looking at the 'Mem Usage' column in Windows,
then that is completely meaningless.

To get a meaningful number, you need to go to View->Select
Columns and check 'Virtual Memory Size'

The new column 'VM Size' will now show you how much memory
your application has actually allocated, rather than how
much it currently has paged into RAM.

What you are seeing with the significant drop in 'Mem Usage'
is Windows throwing most of your program's data set out of
physical RAM when you minimise it.

Now, as to where your 'leak' is coming from - that console
display ain't free. Windows has to buffer that data
somewhere - and that's in RAM.

So if you want to eliminate your 'leak' start the app with
stdout piped to a file.
msg22042 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-08-11 14:39
Logged In: YES 
user_id=11375

Closing as suggested by ncoghlan; this doesn't look like
Python's problem, but rather the console's.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40736
2004-08-10 17:14:47kstrausercreate