Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > windows mem leak

Thread Tools

windows mem leak

Roel Schroeven
Posts: n/a
Peter Hansen wrote:
> Roel Schroeven wrote:
>>> Peter Hansen wrote:
>>>> How have
>>>> you proven that it is not *that* program which is at fault?)

>> It would surprise me: even if it consumes much CPU-time, memory and
>> other resources, each instances returns all resources when it exits.

> I agree with that statement, but you assume that the program *is*
> exiting. And your initial analysis with "fake_nmap" suggests
> that, at least to the extent of having leftover cmd.exe's kicking
> around, maybe it is not.

I see. The number of cmd.exe's running was not *that* big though: about
5-10 I would say. And their PID's kept changing.

I took a look with Process Explorer from sysinternals, which shows the
processes as a tree instead of a simple list. Apparently each fake_nmap
is a child of a cmd.exe, meaning that os.popen indead uses the shell to
run processes. I wouldn't be surprise if cmd.exe would be the culprit here.

"Codito ergo sum"
Roel Schroeven
Reply With Quote
Nick Craig-Wood
Posts: n/a
Bob Smith <(E-Mail Removed)> wrote:
> Attached is the code. Run it yourself and see.

This seems to run nmap over series of consecutive IP addresses. nmap
can do that all by itself. From its man page::

Nmap also has a more powerful notation which lets you specify an IP
address using lists/ranges for each element. Thus you can scan the
whole class 'B' network 128.210.*.* by specifying '128.210.*.*' or
'128.210.0-255.0-255' or even '128.210.1-50,51-255.1,2,3,4,5-255'. And
of course you can use the mask notation: ''. These are
all equivalent. If you use astericts ('*'), remember that most shells
require you to escape them with back slashes or protect them with

This setting might be useful too::

--max_parallelism <number>
Specifies the maximum number of scans Nmap is allowed to perform
in parallel. Setting this to one means Nmap will never try to
scan more than 1 port at a time. It also effects other parallel
scans such as ping sweep, RPC scan, etc.

[sorry not Python related but may solve your problem!]
Nick Craig-Wood <(E-Mail Removed)> --
Reply With Quote
Nick Coghlan
Posts: n/a
Bob Smith wrote:
> Peter Hansen wrote:
>> Bob Smith wrote:
>>> Attached is the code. Run it yourself and see. You too Peter. Be
>>> gentle with me, this was my first attempt with threads.

>> Thanks, Bob, and I will, but not before you answer some of my
>> questions.
>> I had good reasons to ask them, one of which is that I don't
>> feel like wasting my time if, for example, you are using an
>> older version of Python that *did* have a memory leak.

> 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]

Perhaps you could try using the new subprocess module, instead of using os.popen

A fair amount of work went into making the Windows implementation of that module
as solid as the *nix implementation, whereas there may still be issues with
direct os.popen calls (as Roel's investigation suggests).


Nick Coghlan | Removed) | Brisbane, Australia
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
init of class members : mem(0) vs. mem() vs. not-init at all C++ 11 01-29-2011 07:30 PM
allocating mem in a function and assigning a ptr to the first byte of that mem array... C Programming 8 03-01-2007 08:18 AM
mem leak in Singleton? Ethan C++ 7 11-06-2004 01:57 PM
no mem leak but process grows with STL container Steffen Krippner C++ 0 11-14-2003 09:01 AM
no mem leak but process grows with STL container Steffen Krippner C++ 0 11-14-2003 09:01 AM