memory usage (how to debug a memory leak?) 
Author Message
 memory usage (how to debug a memory leak?)

Hi,

I have written a middle scale app using python 2.2.2, wxPython 2.3.
and vtk 4.0 (graphics) on Windows NT.  I have some c-extensions too
(swig 3.1.17)

The app has one ParentFrame and I can open and close ChildFrames
(MDI) and visualilze things in them using vtk.

Everything works as it should, but  the task manager in Windows shows
that the memory usage is not reduced when I close one or more of the
Child Windows . If I close the app all memory is freed and I never get
an error message of any kind.

I tried to del() everything before closing a window, I checked all
refcounts and I checked the swig interfaces. No memory is allocated
inside my c-extensions. Instead I pass a Numeric.array of the right
size to the c-extension and inside the c-code this array is filled
with result values.

Now my question is not what is wrong with my code, but how I can find
out.

Is there any way to get a list like [(object1,sizeof(object1)),...]?
Or a Python tool that tells my something about memory usage?
How do you hunt a memory leak?
Or is it just the Task Manager that's fooling me?

Thanks,
Marcus



Sat, 27 Aug 2005 01:28:14 GMT  
 memory usage (how to debug a memory leak?)

Quote:

> Hi,

> I have written a middle scale app using Python 2.2.2, wxPython 2.3.
> and vtk 4.0 (graphics) on Windows NT.  I have some c-extensions too
> (swig 3.1.17)

> The app has one ParentFrame and I can open and close ChildFrames
> (MDI) and visualilze things in them using vtk.

> Everything works as it should, but  the task manager in Windows shows
> that the memory usage is not reduced when I close one or more of the
> Child Windows . If I close the app all memory is freed and I never get
> an error message of any kind.

> I tried to del() everything before closing a window, I checked all
> refcounts and I checked the swig interfaces. No memory is allocated
> inside my c-extensions. Instead I pass a Numeric.array of the right
> size to the c-extension and inside the c-code this array is filled
> with result values.

> Now my question is not what is wrong with my code, but how I can find
> out.

> Is there any way to get a list like [(object1,sizeof(object1)),...]?
> Or a Python tool that tells my something about memory usage?
> How do you hunt a memory leak?
> Or is it just the Task Manager that's fooling me?

A good starting point is sys.getrefcount(), and in debug builds,
sys.gettotalrefcount().  These can show you if you are leaking
references which is a very common leak in Python extensions.

Once you identify you have one, you basically have to narrow it down via
Python code to the one or 2 extension functions with the problem.

Mark.



Sat, 27 Aug 2005 05:28:49 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. python startup memory size and memory leak

2. memory leak in debug dll for windows

3. memory leak debugging in C modules

4. Uninitialized memory errors and memory leaks in Tk

5. Memory leaks when embedding python (debug-version) ?

6. Memory usage of PHP script/arrays and memory restriction/error

7. optimizing memory usage of large in memory structures

8. memory leak and leak-fixing 'patterns'

9. Possible Dolphi R4 memory leak using ODBC

10. GETDSAB and memory leaks

11. How to pinpoint memory leaks

12. TopLink errors and memory leaks

 

 
Powered by phpBB® Forum Software