This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients amaury.forgeotdarc, loewis, pitrou, rhettinger, serhiy.storchaka
Date 2013-09-19.18:05:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1379613920.2511.10.camel@fsol>
In-reply-to <>
> getsizeof() is interesting only if it gives sensible results when used
> correctly, especially if you want to sum these values and get a global
> memory usage.

"Getting a global memory usage" isn't a correct use of getsizeof(),
though, because it totally ignores the memory allocation overhead (not
to mention fragmentation, or any memory areas that may have been
allocated without being accounted for by __sizeof__).

If you want global Python memory usage, use sys._debugmallocstats(), not

> One usage is to traverse objects through gc.get_referents(); in this
> case the definition above is correct.

What are the intended semantics? get_referents() can give you references
you didn't expect, such as type objects, module objects...

> Now, are you suggesting to traverse objects differently? With dir(),
> or __dict__?

sys.getsizeof() gives you the memory usage of a given Python object, it
doesn't guarantee that "traversing objects" will give you the right
answer for any question.
Date User Action Args
2013-09-19 18:05:25pitrousetrecipients: + pitrou, loewis, rhettinger, amaury.forgeotdarc, serhiy.storchaka
2013-09-19 18:05:25pitroulinkissue19048 messages
2013-09-19 18:05:25pitroucreate