Heapy is powerful but has a learning curve.
This article's main purpose is to show you how to ask heapy various kinds of questions. It may or may not show a few cases where pkgcore uses more memory than it should too.
First, get an x86. Heapy currently does not like 64 bit archs much.
Emerge it:
Open up an interactive python prompt:
Just to show heapy%u2019s internal tricks are:
This object is your %u201Cstarting point%u201D, but as you can see the underlying machinery is not giving away any useful usage instructions.
Do everything that allocates some memory but is not the problem you are tracking down now. Then do:
Everything allocated before this call will not be in the data sets you get later.
Now do your memory-intensive thing:
Keep an eye on system memory consumption. You want to use up a lot but not all of your system ram for nicer statistics.
This object is basically a snapshot of what%u2019s reachable in ram (minus the stuff excluded through setrelheap earlier) which you can do various fun tricks with. Its str() is a summary:
(You might want to keep an eye on ram usage: heapy made the process grow another dozen mb here. It gets slow if it starts swapping, so if that happens reduce your data set).
So here we can see that (we have a ton of strings in memory. We also have various kinds of dicts. Dicts are treated a bit specially: the "dict of pkgcore.ebuild.ebuild_src.package"simply means "all the dicts that are __dict__ attributes of instances of that class". "dict (no owner)" are all the dicts that are not used as __dict__ attribute.
In the next article we're going to discuss how to Get current memory usage of a program using Guppy.
Happy Pythoning..!!
Comments