473,511 Members | 16,730 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need advice on finding memory leak

I am having trouble identifying the source of a memory leak in a
Windows Python program. The basic gist is as follows:
1. Generate a directed graph (approx. 1000 nodes).
2. Write the graph to a file.
3. Use the os.system command to invoke another program which processes
the graph file (graphViz), and generates a gif image of the graph.
4. Use another os.system command to delete the intermediate file, which
is no longer needed.
5. Append to a global list variable some summary information about the
graph (a few floats, a few ints, and a couple of short strings).
6. Repeat the above steps several thousand times.
7. Sort the global summary list.
8. Write the summary information out to a file.

When running this program, Python consumes all memory after about a
thousand graphs.

I have confirmed the following:
1. I am closing all files that I open.
2. Although within the directed graph, nodes refer back and forth to
each other, the main object which manages the directed graph is not
part of anything cyclical. It's reference count is in fact going to
zero when the graph goes out of scope.
3. After running gc.collect(), I have confirmed that the nodes are not
in the garbage list. I interpret this to mean that although their may
be cyclical references among them, the collector was able to determine
that they were unreachable as a group, and successfully collected them.
4. I am generating all these graphs in a for loop (using xrange), not
through a recursive process that would cause the stack to grow.

So really the only thing that should be growing here is the global list
that maintains summary information, and since I'm only adding little
bits of data, it's hard to imagine how this could be exhausting 2GB of
memory after just a thousand iterations.

Can anyone help me think of other possible sources of a leak? Are
there any classic "python-gotchas" I'm missing here, such as something
leaking from calling os.system so many times? Any other suggestions as
to what strategies I could employ to track down the leak?

Thanks,

Mark

Oct 16 '05 #1
1 1882
In message <11**********************@o13g2000cwo.googlegroups .com>,
ma************@gmail.com writes
I am having trouble identifying the source of a memory leak in a
Windows Python program. The basic gist is as follows:


Perhaps Python Memory Validator can help you?

http://www.softwareverify.com/beta.php

Stephen
--
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk/software.html
Computer Consultancy, Software Development
Windows C++, Java, Assembler, Performance Analysis, Troubleshooting
Oct 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1183
by: tianye | last post by:
if my program have memory leak some time i could't exit the program normally but some time i can. how should i do?
8
3394
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
4770
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
4
6056
by: Don Nell | last post by:
Hello Why is there a memory leak when this code is executed. for(;;) { ManagementScope scope = new ManagementScope(); scope.Options.Username="username"; scope.Options.Password="password";...
20
8027
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
6
1850
by: Christopher C | last post by:
I am currently working on an app the will be a shell replacement. Part of the goal is to list the current network status; basically I need to know if the network card is plugged in. I am currently...
13
1518
by: Boni | last post by:
I use 3-d party component. In this component I must pass a reference to my object. The problem is that this component has an ugly bug.When this component is disposed, it incorrectly don't delete...
23
4509
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
3
5292
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5668
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5066
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.