Memory profiling

R

Rune Froysa

I have a fairly large program that uses a number of third-party
modules. After a few hours the program eats several 100M of memory.

Does Python provide any tools that can help in determining where the
memory is used? Ideally, I would like to see a tool that can list all
objects by memory-usage, but any tool that can return the number of
bytes used by an arbitrary object would be of great help. Even
something that could find all allocated dicts&lists and return their
size+name would help.

Regards,
 
M

Michael Hudson

Rune Froysa said:
Does Python provide any tools that can help in determining where the
memory is used?

*Memory*, no. Especially in a debug build, there are tools for
finding out where the objects are, though.
Ideally, I would like to see a tool that can list all objects by
memory-usage, but any tool that can return the number of bytes used
by an arbitrary object would be of great help. Even something that
could find all allocated dicts&lists and return their size+name
would help.

In a debug build, look at sys.getobjects. In a recent release build,
look at gc.get_objects.

Cheers,
mwh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top